Here is an example where all windows except the main window are closed. foreach (Window window in Application.Current.Windows) { if (window != Application.Current.MainWindow) window.Close(); }