Read the docs in the language you think in. Start typing in any script.
English: "beforeunload" · stdlib · javascript
"beforeunload"
Official documentation — MDN reference