@Override
	public void closeComponent() {
		if (display != null) {
			super.closeComponent();
			// to prevent looping, null out display before calling its close method.
			GraphDisplay closingDisplay = display;
			display = null;
			closingDisplay.close();
			removeAllLocalActions();
		}
	}
provided a JComponent for the ProgramGraph visualization
Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplayComponentProvider.java