title: Fire Angularjs event when tab/browser is closed
body: <p>I would like to fire JS code in Angularjs controller. </p>
  
  <p>I have this:</p>
  
  <pre><code>$scope.$on('$destroy', function () {
              alert('page1');
          });
  </code></pre>
  
  <p>This is working fine when I'm navigating away from the page which is using that controller but its not working when I'm closing tab/browser.</p>
  
  <p>Do I need to use some other code to fire JS code when tab/browser is closing?</p>