This fixes a seg. fault on the reopen test because events might occur after the window is destroyed (for example leave events).