How to Fire Angularjs Event when close browser or window?
<p>I want to clear local storage values when user close browser or window tab using in angularjs. I tried the following code.</p>

<pre><code>window.addEventListener("beforeunload", function (e) {
        var confirmationMessage = "\o/";
        alert("exit");
        (e || window.event).returnValue = confirmationMessage; //Gecko + IE
        return confirmationMessage;                            //Webkit, Safari, Chrome
    });
</code></pre>

<p>In the above code it asks the confirmation alert messages when refresh the page and also close the page. But i want to fire angularjs event when close the browser/Window Tab only no need to ask the confirmation messages.</p>