Added a way to trigger the end of the game

Used a boolean variable, gameOver, to trigger the end of the game