public static void Terminate()
        {
            if (!initialized)
            {
                return;
            }
            if (isUpdating)
            {
                terminateScheduled = true;
                return;
            }

            if (environment == ExecutionEnvironment.Editor && execContext == ExecutionContext.Game)
            {
                //Scene.Current.Dispose();
                Logs.Core.Write("CoheeApp terminated in sandbox mode.");
                terminateScheduled = false;
                return;
            }

            if (execContext != ExecutionContext.Editor)
            {
                OnTerminating();
                SaveUserData();
            }

            // Signal that the game simulation has ended.
            if (execContext == ExecutionContext.Game)
            {
                corePluginManager.InvokeGameEnded();
            }

            // Dispose all content that is still loaded
            ContentProvider.ClearContent(true);

            // Discard plugin data (Resources, current Scene) ahead of time. Otherwise, it'll get shut down in ClearPlugins, after the backend is gone.
            corePluginManager.DiscardPluginData();

            //sound.Dispose();
            //sound = null;
            ShutdownBackend(ref graphicsBackend);
            ShutdownBackend(ref audioBackend);

            corePluginManager.ClearPlugins();

            //// Since this performs file system operations, it needs to happen before shutting down the system backend.
            //Profile.SaveTextReport(environment == ExecutionEnvironment.Editor ? "perflog_editor.txt" : "perflog.txt");

            ShutdownBackend(ref systemBackend);

            // Shut down the plugin manager and plugin loader
            corePluginManager.Terminate();
            corePluginManager.PluginsRemoving -= pluginManager_PluginsRemoving;
            corePluginManager.PluginsRemoved  -= pluginManager_PluginsRemoved;
            assemblyLoader.Terminate();
            assemblyLoader = null;

            Logs.Core.Write("CoheeApp terminated");

            initialized = false;
            execContext = ExecutionContext.Terminated;
        }