@Test
	public void testCloseViewWithOpenProgram() throws Exception {

		DomainObject dobj = null;

		// make sure we have projects to use as the project view...
		Project project = ProjectTestUtils.getProject(DIRECTORY_NAME, PROJECT_VIEW1);
		try {
			ToyProgramBuilder builder = new ToyProgramBuilder("Test", true);
			DomainFolder rootFolder = project.getProjectData().getRootFolder();
			rootFolder.createFile("Test", builder.getProgram(), TaskMonitor.DUMMY);
			builder.dispose();
			project.close();

			// get project (create it if it doesn't exist...)
			project = ProjectTestUtils.getProject(DIRECTORY_NAME, PROJECT_NAME1);

			URL view = GhidraURL.makeURL(DIRECTORY_NAME, PROJECT_VIEW1);
			DefaultProjectData projectData =
				(DefaultProjectData) project.addProjectView(view, true);
			Msg.debug(this, "** added view: " + view);
			assertNotNull(projectData);

			DomainFile f = projectData.getFile("/Test");
			assertNotNull(f);

			// Open file and hold onto
			dobj = f.getDomainObject(this, true, false, TaskMonitor.DUMMY);
			Msg.debug(this, "** opened program: " + f);

			assertFalse(projectData.isClosed());
			assertFalse(projectData.isDisposed());

			// remove the view while program open...
			project.removeProjectView(view);
			Msg.debug(this, "** removed view: " + view);

			assertTrue(projectData.isClosed());
			assertFalse(projectData.isDisposed());

			Msg.debug(this, "** releasing program: " + f);
			dobj.release(this);
			dobj = null;

			assertTrue(projectData.isClosed());
			assertTrue(projectData.isDisposed());
		}
		finally {
			if (dobj != null) {
				dobj.release(this);
			}
			project.close();
		}
	}
Test class for adding and a view to a project, and removing
the view from the project.
Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/AddViewToProjectTest.java