Fix build warning.
Fix a potential simulation shutdown issue.