Detecting a user closing a form without submitting it.

Detecting a user closing a form without submitting it.

I probably know the answer to this but I though I'd just ask in case someone has found a way to do this. 
is there a some kind of on close or on quit event where deluge script can be run when a user cancels or closes a form or quits the window that a form is open without submitting or updating a form.?
It would be useful for us to do some data clear up if this happened to one of our forms.

Thanks