Fixes an issue where the program crashes after leaving it for a while.