       (let ((comint-prompt-read-only nil)
             (comint-input-ring-file-name (geiser-repl--history-file)))
         (geiser-repl--on-quit)
+        (push (current-buffer) geiser-repl--closed-repls)
         (when (buffer-name (current-buffer))
           (insert "\nIt's been nice interacting with you!\n")
           (insert "Press C-cz to bring me back.\n" ))))))
+
+(defun geiser-repl--on-kill ()
+  (geiser-repl--on-quit)
+  (remove (current-buffer) geiser-repl--closed-repls))
 
 (defun geiser-repl--input-filter (str)
   (and (not (string-match "^\\s *$" str))

(defsubst geiser-repl--set-this-buffer-repl (r)
  (setq geiser-repl--repl r))

(defun geiser-repl--repl/impl (impl)
  (catch 'repl
    (dolist (repl geiser-repl--repls)
      (with-current-buffer repl
        (when (eq geiser-impl--implementation impl)
          (throw 'repl repl))))))

;;; Geiser REPL buffers and processes:

(defvar geiser-repl--repls nil)
(defvar geiser-repl--closed-repls nil)

(make-variable-buffer-local
 (defvar geiser-repl--repl nil))
