Correct. You can only detect when the page is unloaded, not when the window is closed. Also, the onbeforeunload is non-standard, so it's not supported by all browsers.
I wanted to use the 'on close' feature as well, but noticed that my users will occasionally refresh the screen by pressing F5. Since my 'on close' handlers are invoked on such refresh, this means I can't use it the way I needed it (which was a true 'close tab or window')... damn it, we need a new event model for all of this!
Of course this will still work, they just removed a custom String return value from onbeforeunload. So now you're no longer be able to display a custom message before unloading.
This works for me. However, my issue is a little more complicated. I'm trying to pass parameters into a method I assign to onbeforeunload from the codebehind. Could someone stop by stackoverflow.com/questions/28305430/ and weigh in?