Lib: add unload event.

Add support for the [`unload`](https://developer.mozilla.org/en-US/docs/Web/Events/unload) event.