Fix for invalid operation exception in GL when exiting the game.