We can check for browser close event through Javascript.
Here is the sample code that checks for browser or tab close using Javascript

<title>Browser Close Check</title>
<script type=”text/javascript”>
function confirmExit(){
return “Your information is not saved. Do u really want to close this page?”
<h4>Browser Close Checking</h4>

The event ‘onbeforeunload’ fires before the document is unloaded.
The document will be unloaded when the user navigates to a different URL or attempts to close the browser window.

After executing the above script, when we close the browser it will fire the ‘onbeforeunload’ event, which in turn calls the function ‘confirmExit’. This function will alert the specified custom message.

By this way we can customize the browser close event.