i have searched the same and i got
$(window).on('beforeunload', function() {
return 'Are you sure you want to leave?';
});
$(window).on('unload', function() {
logout();
});
But above functions work on every request .i just want to check only browser close event usning javascript or jQuery. Thank you