[giow] (3) Bring onbeforeunload handling closer to

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=19713