                  ;; This coordination is needed until we no longer
                  ;; support jdk < 10.
                  ;; https://bugs.openjdk.java.net/browse/JDK-8176254
-                 :stop-status (atom #{}))))
+                 :stop-status (atom #{})
+                 :shutdown-request (promise))))
   (start
    [this context]
    (start-puppetdb-or-shutdown context (get-config) this
                                get-registered-endpoints
-                               shutdown-on-error))
+                               (shutdown-requestor request-shutdown
+                                                   shutdown-on-error
+                                                   this)))
 
   (stop [this context]
         (doseq [{:keys [reporter]} (vals metrics/metrics-registries)]

                                                context
                                                read-db
                                                service
                                                shutdown-on-error)
                         job-pool))
          (when (pos? gc-interval-millis)
            (let [request (db-config->clean-request database)]

    (async/>!! cmd-event-ch (queue/make-cmd-event cmdref kind))))

(defn check-schema-version
  [desired-schema-version context db service request-shutdown]
  {:pre [(integer? desired-schema-version)]}
  (when-not (= #{:stopping} @(:stop-status context))
    (let [schema-version (-> (jdbc/with-transacted-connection db
