public static void closeAllWindows(boolean showError) {
		boolean firstClose = true;
		for (Window window : getAllWindows()) {

			if (!window.isShowing()) {
				continue;
			}

			if (showError) {

				if (firstClose) { // only print once
					firstClose = false;
					printOpenWindows();
				}

				// note: we use System.err here to get more obvious errors in the console
				String title = getDebugTitleForWindow(window);
				System.err.println("DockingTestCase - Forced window closure: " + title);
				String errorMessage = getMessageText(window);
				if (errorMessage != null) {
					System.err.println("\tWindow error message: " + errorMessage);
				}
			}

			Window w = window;
			runSwing(() -> w.dispose());
		}
	}
Will try to close dialogs prompting for changes to be saved, whether from program changes
or from tool config changes.
Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java