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
@mterjeki please use addValueChangeListenerAndApply from the superclass - that will also handle the initial value.