Added condition for game ending

re #9