diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index c0bdc552582e93cc2cd44042534deefa581b2957..6c1a8e1bbaa40478c24cbfcdcc6aa0c09e8eee73 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -695,7 +695,7 @@ public function getServiceProviders($origin) {
    * @return void
    */
   public function terminate(Request $request, Response $response) {
-    if ($this->getHttpKernel() instanceof TerminableInterface) {
+    if ($this->booted && $this->getHttpKernel() instanceof TerminableInterface) {
       // Only run terminate() when essential services have been set up properly
       // by preHandle() before.
       if ($this->prepared === TRUE) {
diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
index 95630123c3483bc0dc91faf357f40f94d6adc963..8c86bd922e1b5d347905d3a0555fbe6ed84a5a9f 100644
--- a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
@@ -4,12 +4,14 @@
 
 namespace Drupal\Tests\Core\DrupalKernel;
 
+use Composer\Autoload\ClassLoader;
 use Drupal\Core\DrupalKernel;
 use Drupal\Core\Test\TestKernel;
 use Drupal\Tests\Core\DependencyInjection\Fixture\BarClass;
 use Drupal\Tests\UnitTestCase;
 use org\bovigo\vfs\vfsStream;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 
 /**
  * @coversDefaultClass \Drupal\Core\DrupalKernel
@@ -152,6 +154,16 @@ public function testGetServiceIdMapping() {
     $this->assertEquals($container->get('kernel')->getServiceIdMapping()[$container->generateServiceIdHash($service)], 'bar');
   }
 
+  /**
+   * @covers ::terminate
+   * @runInSeparateProcess
+   */
+  public function testUnBootedTerminate() {
+    $kernel = new DrupalKernel('test', new ClassLoader());
+    $kernel->terminate(new Request(), new Response());
+    $this->assertTrue(TRUE, "\Drupal\Core\DrupalKernel::terminate() called without error on kernel which has not booted");
+  }
+
 }
 
 /**