Fix crash when the view was not removed from the window manager in time.