Fix the bug that the game will get stuck at the end of the level