public async Task Exit(bool immediately = false) { if (this.IsInitialized && !immediately) { await DisposeWorkplace(true); } foreach (IComponent commonComponent in CommonComponents.Where(c => c is IDisposable)) { (commonComponent as IDisposable)?.Dispose(); } Application.Exit(); }