The beforeunload event is fired when the window, the document and its resources are about to be unloaded. View Source js/lib.dom.d.ts, line 422