added Onbeforeunload event

Probably it could be the best solution for handle this correctly:
http://stackoverflow.com/questions/14645011/window-onbeforeunload-and-window-onunload-is-not-working-in-firefox-safari-o
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.removeEventListener
yes, this is ok. We did what we can ...