added game ending function