Fix for Bug 256839 [Workbench] Workbench.shutdown() doesn't complete due to exception
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java
index f8b54a5..1b0526b 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java
@@ -183,8 +183,14 @@
 					}
 					// For all other exceptions, log the problem.
 					catch (Throwable t) {
+						if (t instanceof VirtualMachineError) {
+							throw (VirtualMachineError) t;
+						}
 						exceptionCount++;
-						if (exceptionCount > 2 || display.isDisposed()) {
+						// We're counting exceptions in client code, such as asyncExecs,
+						// so be generous about how many may fail consecutively before we
+						// give up.
+						if (exceptionCount > 50 || display.isDisposed()) {
 			                if (t instanceof RuntimeException) {
 								throw (RuntimeException) t;
 							} else if (t instanceof Error) {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
index 9857ffa..b55f14f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
@@ -2705,7 +2705,13 @@
 	 */
 	private void shutdown() {
 		// shutdown application-specific portions first
-		advisor.postShutdown();
+		try {
+			advisor.postShutdown();
+		} catch (Exception ex) {
+			StatusManager.getManager().handle(
+					StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
+							"Exceptions during shutdown", ex)); //$NON-NLS-1$
+		}
 
 		// notify regular workbench clients of shutdown, and clear the list when
 		// done