   "Handle PROC's output (STRING)."
   (when string
     (fstar-subp-log "OUTPUT [%s]" string)
-    (fstar-subp-with-process-buffer proc t
-      (goto-char (point-max))
-      (insert string)
-      (fstar-subp-find-response proc))))
+    (when (fstar-subp-live-p proc)
+      (fstar-subp-with-process-buffer proc
+        (goto-char (point-max))
+        (insert string)
+        (fstar-subp-find-response proc)))))
 
 (defun fstar-subp-buffer-killed ()
   "Kill F* process associated to current buffer."
   (-when-let* ((proc (get-buffer-process (current-buffer))))
-    (run-with-timer 0 nil #'fstar-subp-kill proc)))
+    (run-with-timer 0 nil #'fstar-subp-kill-proc proc)))
 
 (defun fstar-subp-make-buffer ()
   "Create a buffer for the F* subprocess."

  (setq proc (or proc fstar-subp--process))
  (and proc (process-live-p proc)))

(defun fstar-subp-killed (proc)
  "Clean up buffer after PROC was killed."
  (fstar-subp-with-process-buffer proc nil
    (kill-buffer))
  (fstar-subp-remove-tracking-overlays)
  (fstar-subp-remove-issues-overlays)
  (setq fstar-subp--busy-now nil
        fstar-subp--process nil))

(defun fstar-subp-kill (&optional proc)
  "Kill F* subprocess PROC and clean up buffer."
  (interactive)
  (setq proc (or proc fstar-subp--process))
  (when (fstar-subp-live-p proc)
    (kill-process proc)
    (accept-process-output proc 0.25 nil t))
  (fstar-subp-with-source-buffer proc nil
    (fstar-subp-killed proc)))

(defun fstar-subp-sentinel (proc signal)
  "Handle PROC's SIGNAL."
  (fstar-subp-log "SENTINEL [%s] [%s]" signal (process-status proc))
  (when (or (memq (process-status proc) '(exit signal))
	    (not (process-live-p proc)))
    (fstar-subp-killed proc)))

(defun fstar-subp-remove-tracking-overlays ()
  "Remove all F* overlays in the current buffer."

      ;; string-trim is defined by flycheck if not present
      (fstar-subp-log "RESPONSE [%s] [%s]" status response)
      (delete-region resp-beg resp-real-end)
      (when (fstar-subp-live-p proc)
        (fstar-subp-with-source-buffer proc
          (fstar-subp-process-response status response))))))

(defun fstar-subp-clear-issues ()
  "Remove all issue overlays from current buffer."
