Prevent crashing when abruptly closing the game. AH-363