Fixes crashing when "unload" event handler tries to access active document that has already been destroyed.