Dispatching event on exit

Does flash dispatch any event just before it’s closed?
e.g. When the user closes the browser?
I searched the documentation and there’s nothing. I thought the stage should dispatch an event.
If there isn’t any can I make a custom one?
I need this for server-side solution.