   [s]
   (log/info (str "Closing scope: \n" s))
   (let [{:keys [id bus-synth buf]} s]
-    (when bus-synth (kill bus-synth))
+    (when (and bus-synth
+               (connected?))
+      (kill bus-synth))
     (dosync (alter scopes* dissoc id))))
 
 (defn- mk-scope

(defn pscope
  "Creates a 'perminent' scope, i.e. one where the window is always kept on top of other OS windows. See scope."
  ([& args]
     (apply scope (concat args [:keep-on-top true]))))

(defn- reset-scopes
  "Restart scopes if they have already been running"
  []
  (dosync
   (ref-set scopes*
            (reduce (fn [new-scopes [k v]]

        (.scale 1 (* -1 y-zoom))
        (.drawPolyline ^ints x-array ^ints y-a width)))))

(defn- scope-panel [id width height]
  (let [panel (proxy [JPanel] [true]
                (paint [g] (paint-scope g id)))
        _ (.setPreferredSize panel (Dimension. width height))]
