Fix for window unload issue

See Firefox bug 835011

https://bugzilla.mozilla.org/show_bug.cgi?id=835011