diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 8fa9e70a0..187a4a6da 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -156,6 +156,8 @@ public sealed class EntryPoint AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; + var unloadFailed = false; + try { if (info.DelayInitializeMs > 0) @@ -180,7 +182,15 @@ public sealed class EntryPoint dalamud.WaitForUnload(); - ServiceManager.UnloadAllServices(); + try + { + ServiceManager.UnloadAllServices(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Could not unload services."); + unloadFailed = true; + } } catch (Exception ex) { @@ -195,6 +205,11 @@ public sealed class EntryPoint Log.CloseAndFlush(); SerilogEventSink.Instance.LogLine -= SerilogOnLogLine; } + + // If we didn't unload services correctly, we need to kill the process. + // We will never signal to Framework. + if (unloadFailed) + Environment.Exit(-1); } private static void SerilogOnLogLine(object? sender, (string Line, LogEvent LogEvent) ev) @@ -327,7 +342,7 @@ public sealed class EntryPoint } var pluginInfo = string.Empty; - var supportText = ", please visit us on Discord for more help."; + var supportText = ", please visit us on Discord for more help"; try { var pm = Service.GetNullable();