You're actually wanting to use the onbeforeunload
event which allows you to block the close event.
See the MDN reference for details, but the code required would be:
window.onbeforeunload = function(e) {
return 'Please press the Logout button to logout.';
};