title: Fire onbeforeunload only when window is closed (includes working example)
body: <p>I want to fire the onbeforeunload event only when the tab or browser is closed and not upon refresh, link click and so on. I found a site where that works: <a href="https://checkout.deindeal.ch/" rel="nofollow">https://checkout.deindeal.ch/</a></p>
  
  <p>Steps to fire the event in Chrome:</p>
  
  <ol>
  <li>Put something into the cart</li>
  <li>Click on "Zur Kasse"</li>
  <li>Close tab </li>
  <li>onbeforeunload Message is shown and a popup opens. onbeforeunload events like refresh will not fire. I debugged their code, but could not find the place where they exclude those events or whatsoever. </li>
  </ol>
  
  <p>Anyone out there who can find the correct place in the code?</p>
  
  <p>Thanks!</p>