title: Javascript/jQuery beforeunload and unload not firing
body: <p>I have a page where I want my script to let the server know that the user went offline when the browser/tab/page is closed.</p>
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
      // Inform the server that the user went online
      setStatus('online');
  
      // Inform the server that the user went offline
      $(window).on('beforeunload', function() {
          setStatus('offline');
      });
  
      // Inform the server that the user went offline
      $(window).on('unload', function() {
          setStatus('offline');
      });
  });
  
  async function setStatus(status) {
      let { data } = await axios.post('/status', { status: status });
  }
  </code></pre>
  <p>The part where I have <code>setStatus('online');</code> works but I can never seem to set the status to <code>offline</code> when I close the page/tab/browser.</p>