Fix crash when toggling fullscreen