public void Terminate() => ThreadPool.QueueUserWorkItem(async state => { addOnManager.AddOnAutomaticallyUpdated -= AddOnManagerAddOnAutomaticallyUpdatedHandler; addOnManager.AddOnUpdateAvailable -= AddOnManagerAddOnUpdateAvailableHandler; addOnManager?.Dispose(); worldOfWarcraftInstallation?.Dispose(); await File.WriteAllTextAsync(stateFile.FullName, JsonConvert.SerializeObject(new AppState { MainWindowHeight = MainWindowHeight, MainWindowLeft = MainWindowLeft, MainWindowTop = MainWindowTop, MainWindowWidth = MainWindowWidth, ShowPrereleaseVersions = ShowPrereleaseVersions, ThemeIsDark = ThemeIsDark, ThemeIsHorde = ThemeIsHorde })).ConfigureAwait(false); singleInstance?.Dispose(); await OnUiThreadAsync(() => Shutdown()).ConfigureAwait(false); });