diff --git a/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php
index 584b141..7e4cf9e 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php
@@ -13,7 +13,7 @@
 use Drupal\Core\Routing\RoutingEvents;
 use Symfony\Component\EventDispatcher\Event;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpKernel\Event\PostResponseEvent;
+use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
 use Symfony\Component\HttpKernel\KernelEvents;
 
 /**
@@ -39,10 +39,10 @@ public function __construct(RouteBuilderInterface $route_builder) {
   /**
    * Rebuilds routers if necessary.
    *
-   * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
+   * @param \Symfony\Component\HttpKernel\Event\FinishRequestEvent $event
    *   The event object.
    */
-  public function onKernelTerminate(PostResponseEvent $event) {
+  public function onKernelFinishRequest(FinishRequestEvent $event) {
     $this->routeBuilder->rebuildIfNeeded();
   }
 
@@ -50,7 +50,7 @@ public function onKernelTerminate(PostResponseEvent $event) {
    * {@inheritdoc}
    */
   static function getSubscribedEvents() {
-    $events[KernelEvents::TERMINATE][] = array('onKernelTerminate', 200);
+    $events[KernelEvents::FINISH_REQUEST][] = ['onKernelFinishRequest', 200];
     return $events;
   }
 
