Updated game ending code