public static void OnApplicationQuit() { if (Plugins.Count > 0) { for (int i = 0; i < Plugins.Count; i++) { MelonPlugin plugin = Plugins[i]; if (plugin != null) { try { plugin.OnApplicationQuit(); } catch (Exception ex) { MelonModLogger.LogDLLError(ex.ToString(), plugin.InfoAttribute.Name); } } } } if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnApplicationQuit(); } catch (Exception ex) { MelonModLogger.LogDLLError(ex.ToString(), mod.InfoAttribute.Name); } } } } if ((Plugins.Count > 0) || (Mods.Count() > 0)) { ModPrefs.SaveConfig(); } Harmony.HarmonyInstance.UnpatchAllInstances(); Imports.UNLOAD_MELONLOADER(); if (Imports.IsQuitFix()) { Process.GetCurrentProcess().Kill(); } }