title: I need JavaScript (Angular) event listener for closing page and tabs
body: <p>I need event that will work on closing page or tab, but also will not trigger on refreshing page. I know for &quot;beforeunload&quot;, but that still work on refreshing page.</p>
  <p>Here is my code</p>
  <pre><code>@HostListener('window:beforeunload', ['$event'])
  checkIsUserLogOut() {
      if (ConfigurationModel.applicationOptions.autoLogOutWhenWebBrowserClosed) {
          localStorage.removeItem('auth_token');
          localStorage.removeItem('auth_token_expires_on');
      }
  }
  </code></pre>