If you read
this[
^], you'll see that using the unload event is unreliable. If you're able to get it to fire at all, then you can use conditional logic to reload your page if you don't want to let the user leave it. This is, however, horrible UI. If your user decides to close your page, you should let them, and work out a different way to deal with the fact that they have. From what I can see, the unload event doesn't allow you to stop the page loading, which is why you have to reload the page if you want to stop them. Of course, if they close the browser, there's nothing you can do.