private void Window_Closing(object sender, CancelEventArgs e) { if (ChatMgr.CheckIfPendingChat()) { if (!DialogUtils.ShowQuestion(this, "You have open windows, are you sure you want to close the application?")) { e.Cancel = true; return; } } Disconnect(); foreach (Window owned in OwnedWindows) { owned.Close(); } ChatMgr.Clear(); RosterMgr.Clear(); if (tracer != null) { tracer.Close(); } if (logger != null) { logger.Close(); } }