Fix possible savestate/shutdown issue.