diff --git a/devel.module b/devel.module
index 7b810b1..cd29da0 100644
--- a/devel.module
+++ b/devel.module
@@ -377,18 +377,6 @@ function devel_get_core_version($version) {
 }
 
 /**
- * Runs on shutdown to clean up and display developer information.
- *
- * DevelEventSubscriber::onRequest registers this function as a shutdown function.
- * The bulk of the work is done in devel_shutdown_real().
- */
-function devel_shutdown() {
-  // Register the real shutdown function so it runs after other shutdown
-  // functions.
-  drupal_register_shutdown_function('devel_shutdown_real');
-}
-
-/**
  * Implements hook_page_attachments_alter().
  */
 function devel_page_attachments_alter(&$page) {
@@ -422,9 +410,10 @@ function devel_ajax_render_alter() {
 }
 
 /**
- * Runs on shutdown to display developer information in the footer.
+ * Collect data to be displayed on the page.
+ * This function should be called by an event subscriber as implemented in
+ * DevelEventSubscriber::onResponseLate().
  *
- * devel_shutdown() registers this function as a shutdown function.
  */
 function devel_shutdown_real() {
   $output = $txt = '';
@@ -465,7 +454,7 @@ function devel_shutdown_real() {
       // See drupal_page_header().
       // For some reason, this is not actually printing for cached pages even
       // though it gets executed and $output looks good.
-      print $output;
+      return $output;
     }
   }
 }
diff --git a/src/EventSubscriber/DevelEventSubscriber.php b/src/EventSubscriber/DevelEventSubscriber.php
index 147c6ec..85af745 100644
--- a/src/EventSubscriber/DevelEventSubscriber.php
+++ b/src/EventSubscriber/DevelEventSubscriber.php
@@ -157,6 +157,18 @@ class DevelEventSubscriber implements EventSubscriberInterface {
   }
 
   /**
+   * Display the debug informations at the end of the page.
+   *
+   * @param FilterResponseEvent $event
+   */
+  public function onResponseLate(FilterResponseEvent $event) {
+    $response = $event->getResponse();
+    if ($devel_content = devel_shutdown_real()) {
+      $response->setContent($response->getContent() . $devel_content);
+    }
+  }
+
+  /**
    * Implements EventSubscriberInterface::getSubscribedEvents().
    *
    * @return array
@@ -169,6 +181,9 @@ class DevelEventSubscriber implements EventSubscriberInterface {
     // Why only large positive value works here?
     $events[KernelEvents::RESPONSE][] = array('onResponse', 1000);
 
+    // Modify the response. Be sure to do this very late in the process.
+    $events[KernelEvents::RESPONSE][] = array('onResponseLate', 9999);
+
     return $events;
   }
 
