diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 1757acd..9985d50 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -175,7 +175,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;
     }
   }
 
@@ -187,7 +187,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 6a08211..f5e23b9 100644
--- a/core/modules/system/tests/modules/session_test/session_test.module
+++ b/core/modules/system/tests/modules/session_test/session_test.module
@@ -1,13 +1,15 @@
 <?php
 
+use Symfony\Component\HttpFoundation\Response;
+
 /**
  * Implements hook_user_login().
  */
 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");
