Updated exitMaze method