beforeunload event, fixes #33
Merge pull request #21 from ondras/master

beforeunload event, fixes #33