Function for ending the game