       (when (and (@state :init-continuous-focus)
                  (not (core isContinuousFocusEnabled)))
         (enable-continuous-focus true))
-      (when gui (.enableRoiButtons gui true)))
+      (when gui (.enableRoiButtons gui true))
+      (unsubscribe-state-from-core-callbacks state))
     (catch Throwable t 
            (ReportingUtils/showError t "Acquisition cleanup failed."))))
 

           :pixel-type (get-pixel-type)
           )))

(defn cleanup []
  (try
    (attempt-all

          (.enableRoiButtons false)))
      (prepare-state state (when (:use-position-list settings) position-list) autofocus-device)
      (def last-state state) ; for debugging
      (subscribe-state-to-core-callbacks state)
      (let [acq-seq (generate-acq-sequence settings @attached-runnables)]
        (def acq-sequence acq-seq) ; for debugging
        (execute (mapcat #(make-event-fns % out-queue) acq-seq)))
