Fix the problem with window not closing after game is finished