On close window, call function

Hi, I’m trying to have a function called when the user closes a window. Here is the code I’m using at the moment:

<body onUnload=fadeBack();>
‘fadeBack’ is the name of the function.

The problem is that onUnload also works when the page changes to another url. I only want it to work when the user actually closes the window. Is this possible? Is there an onUnload alternative which is specific to window closing?

Thanks.