diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index e3ad1c8..7b25618 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -184,7 +184,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
       // Should not translate the string to avoid errors producing more errors.
       $response->setContent(html_entity_decode(strip_tags(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error))) . "\n");
       $response->send();
-      exit;
+      return;
     }
   }
 
@@ -196,7 +196,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
         $response->setContent(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error));
         $response->send();
       }
-      exit;
+      return;
     }
   }
   else {
diff --git a/core/modules/system/tests/modules/session_test/session_test.module b/core/modules/system/tests/modules/session_test/session_test.module
index b3ceff8..2b8d45c 100644
--- a/core/modules/system/tests/modules/session_test/session_test.module
+++ b/core/modules/system/tests/modules/session_test/session_test.module
@@ -1,5 +1,7 @@
 <?php
 
+use Symfony\Component\HttpFoundation\Response;
+
 /**
  * @file
  * Test module.
@@ -11,8 +13,8 @@
 function session_test_user_login($account) {
   if ($account->getUsername() == 'session_test_user') {
     // Exit so we can verify that the session was regenerated
-    // before hook_user_login() was called.
-    exit;
+    // before hook_user() was called.
+    return new Response('OK', Response::HTTP_OK );
   }
   // Add some data in the session for retrieval testing purpose.
   \Drupal::request()->getSession()->set("session_test_key", "foobar");
