title: Clear localStorage on tab/browser close but not on refresh
body: <p>Is there a way to detect tab close event to clear the <code>localStorage</code>. I need <code>localStorage</code> to share data across tabs. <code>window.onbeforeunload</code> event works fine but it has 2 issues for me:</p>
  
  <ol>
  <li>It also fires on page refresh which I dont want. </li>
  <li>I don't need confirm box on tab close.</li>
  </ol>
  
  <p>Like when window is closed the <code>sessionStorage</code> is cleared. At same time I can clear <code>localStorage</code> but don't know what event to bind to. I checked a few questions already available but none seems to address this issue there are workarounds by using flags for click on links and form submits but not a clean way to do it. Kindly suggest any solution for this. </p>