fixed #162 crash at the end of the game