+ delete renderer;
+// The AIModels manager performs a number of actions upon
+ // Shutdown that implicitly assume that other subsystems
+ // are still operational (Due to the dynamic allocation and
+ // deallocation of AIModel objects. To ensure we can safely
+ // shut down all subsystems, make sure we take down the
+ // AIModels system first.
+ subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("ai_model");
+ // FGInput (FGInputEvent) and FGDialog calls get_subsystem() in their destructors,
+ // which is not safe since some subsystem are already deleted but can be referred.
+ // So these subsystems must be deleted prior to deleting subsystem_mgr unless
+ // ~SGSubsystemGroup and SGSubsystemMgr::get_subsystem are changed not to refer to
+ // deleted subsystems.
+ subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("input");
+ subsystem_mgr->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("gui");
+ subsystem_mgr->unbind();