diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
index <HASH>..<HASH> 100644
--- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
+++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
@@ -360,18 +360,25 @@ public class SpringApplication {
 			return context;
 		}
 		catch (RuntimeException ex) {
-			multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context,
-					args, ex));
+			handleError(context, multicaster, ex, args);
 			throw ex;
 		}
 		catch (Error ex) {
-			multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context,
-					args, ex));
+			handleError(context, multicaster, ex, args);
 			throw ex;
 		}
 
 	}
 
+	protected void handleError(ConfigurableApplicationContext context,
+			ApplicationEventMulticaster multicaster, Throwable ex, String... args) {
+		multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context, args,
+				ex));
+		if (context != null) {
+			context.close();
+		}
+	}
+
 	private void registerListeners(ApplicationEventMulticaster multicaster,
 			Set<Object> sources) {
 		for (Object object : sources) {
Ensure SpringApplication closes its ApplicationContext

...even if the CommandLineRunners fail and we drop to the error
handling path.

Fixes gh-<I>