The game ends if the snake collides with the walls or itself.