Fixed a bug where game would close unexpectedly