Fix typo
Use beforeunload event
Merge pull request #4 from martin-g/use-beforeunload

Use beforeunload event