internal async Task <bool> Close() { if (!IdeApp.OnExit()) { return(false); } IdeApp.Workspace.SavePreferences(); bool showDirtyDialog = false; foreach (var doc in Documents) { if (doc.IsDirty) { showDirtyDialog = true; break; } } if (showDirtyDialog) { using (var dlg = new DirtyFilesDialog()) { dlg.Modal = true; if (MessageService.ShowCustomDialog(dlg, workbench) != (int)Gtk.ResponseType.Ok) { return(false); } } } if (!await IdeApp.Workspace.Close(false, false)) { return(false); } var tasks = new List <Task> (); foreach (var doc in Documents.ToList()) { tasks.Add(doc.Close(true)); } await Task.WhenAll(tasks); workbench.Close(); IdeApp.Workspace.SavePreferences(); IdeApp.OnExited(); IdeApp.CommandService.Dispose(); return(true); }