fixed NPE on leaving gamemode (fixes #554)