Detecting if the user browser closes the browser
<p>I have a website with master page. I want to catch a user trying to close the browser/tab. When I try using <code>onunload</code> in the body tag, it fires not only when I try closing the browser, but also when I navigate to another page.</p>

<p>Any idea how to only catch the event of closing the browser?</p>
