add beforeunload event /cc @gaurangtandon
Merge pull request #1 from JoahG/patch-1

add beforeunload event