[91636] JSP Indexing doesn't shutdown when plugin does -- a few last cases.
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager.java
index 76f5bef..aefff40 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager.java
@@ -58,6 +58,9 @@
 
 	private static final String PKEY_INDEX_STATE = "jspIndexState"; //$NON-NLS-1$
 
+	final IndexWorkspaceJob indexingJob = new IndexWorkspaceJob();
+
+
 
 	// set to S_UPDATING once a resource change comes in
 	// set to S_STABLE if:
@@ -219,7 +222,7 @@
 		}
 
 		protected IStatus run(IProgressMonitor monitor) {
-			//System.out.println("indexer monitor" + monitor);
+			// System.out.println("indexer monitor" + monitor);
 			if (isCanceled(monitor) || frameworkIsShuttingDown()) {
 				setCanceledState();
 				return Status.CANCEL_STATUS;
@@ -473,8 +476,6 @@
 		if (DEBUG)
 			System.out.println("*** JSP Index unstable, requesting re-indexing"); //$NON-NLS-1$
 
-		final IndexWorkspaceJob indexingJob = new IndexWorkspaceJob();
-
 		indexingJob.addJobChangeListener(new JobChangeAdapter() {
 			public void aboutToRun(IJobChangeEvent event) {
 				super.aboutToRun(event);
@@ -574,14 +575,28 @@
 
 
 	public void shutdown() {
+		int maxwait = 5000;
 		if (processFilesJob != null) {
 			processFilesJob.cancel();
 		}
-		// attempt to make sure this indexing job is litterally 
+		// attempt to make sure this indexing job is litterally
 		// done before continuing, since we are shutting down
-		while (processFilesJob.getState() == Job.RUNNING) {
+		waitTillNotRunning(maxwait, processFilesJob);
+		
+		if (indexingJob != null) {
+			indexingJob.cancel();
+		}
+		waitTillNotRunning(maxwait, processFilesJob);
+	}
+
+	private void waitTillNotRunning(int maxSeconds, Job job) {
+		int pauseTime = 10;
+		int maxtries = maxSeconds / pauseTime;
+		int count = 0;
+		while (count++ < maxtries && job.getState() == Job.RUNNING) {
 			try {
-				Thread.sleep(50);
+				Thread.sleep(pauseTime);
+				//System.out.println("count: " + count + " max: " + maxtries);
 			}
 			catch (InterruptedException e) {
 				Logger.logException(e);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java
index 1e94b7d..918e9ca 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java
@@ -63,7 +63,15 @@
 	}
 
 	private Display getDisplay() {
-		return PlatformUI.getWorkbench().getDisplay();
+		Display display = null;
+		IWorkbench workbench = null;
+		if (PlatformUI.isWorkbenchRunning()) {
+			workbench = PlatformUI.getWorkbench();
+		}
+		if (workbench != null && !workbench.isClosing()) {
+			display = workbench.getDisplay();
+		}
+		return display;
 	}
 
 	private void setStatusLine(final String message) {
@@ -96,8 +104,10 @@
 					}
 				}
 			};
-			Display workbenchDefault = PlatformUI.getWorkbench().getDisplay();
-			workbenchDefault.asyncExec(runnable);
+			Display workbenchDefault = getDisplay();
+			if (workbenchDefault != null) {
+				workbenchDefault.asyncExec(runnable);
+			}
 		}
 	}
 }