         camera-index-tag (str (. mmc getCameraDevice) "-CameraChannelIndex")
         image-number-offset (if (first-trigger-missing?) -1 0)
         image-queue (pop-burst-images total timeout-ms)]
-    (doseq [i (range total) :while (not (@state :stop))]
-      ;(println i)
-      (.put out-queue
-            (-> (.take image-queue)
-                (tag-burst-image burst-events camera-channel-names camera-index-tag
-                                 image-number-offset)
-                make-TaggedImage
-                ))))
-  (burst-cleanup))
+    (try
+      (doseq [i (range total)]
+        (send-tagged-image
+          out-queue
+          (let [image (try
+                        (.take image-queue)
+                        (catch RuntimeException e
+                          (if (.getCause e) ; unwrap rethrown exception
+                            (throw (.getCause e))
+                            (throw e))))]
+            (-> image
+              (tag-burst-image burst-events camera-channel-names camera-index-tag
+                               image-number-offset)
+              make-TaggedImage))))
+      (finally (burst-cleanup)))))
 
 (defn collect-burst-images [event out-queue]
   (let [pop-timeout-ms (+ 20000 (* 10 (:exposure event)))]

    (future (try
              (dotimes [_ n]
                (try (.put queue (function))
                     (catch Throwable t
                            (.put queue t)
                            (throw t))))
              (catch Throwable t nil)))
    queue))


        camera-channel-name (nth camera-channel-names cam-chan)
        num-camera-channels (count camera-channel-names)
        event (-> burst-event
                (update-in [:channel-index]
                           make-multicamera-channel
                           cam-chan num-camera-channels)
                (update-in [:channel :name]
                           super-channel-name
                           camera-channel-name num-camera-channels)
                (assoc :camera-channel-index cam-chan))
        time-stamp (burst-time (:tags image) @state)]
    (annotate-image image event @state time-stamp)))

(defn send-tagged-image
  "Send out image to output queue, but avoid hanging if we stop while blocking
  on the output queue"
  [out-queue tagged-image]
  (loop []
    (when (@state :stop)
      (log "canceling image output due to engine stop")
      (throw (EOFException. "(Aborted)")))
    (when (not (.offer out-queue tagged-image 1000 (TimeUnit/MILLISECONDS)))
      (recur))))

(defn produce-burst-images
  "Pops images from circular buffer, tags them, and sends them to output queue."
