            :server-process (get-buffer-process server)
            :client-process client
            :client-buffer (process-buffer client)))
-    (set-process-filter client #'emacspeak-maths-process-filter)))
+    (set-process-filter client #'emacspeak-maths-process-filter)
+    (message "Started Maths server and client.")))
+
+(defun emacspeak-maths-shutdown()
+  "Shutdown math-server and client."
+  (interactive)
+  (declare (special emacspeak-maths))
+  (when (process-live-p (emacspeak-maths-client-process emacspeak-maths))
+    (delete-process (emacspeak-maths-client-process emacspeak-maths)))
+  (when (process-live-p (emacspeak-maths-server-process emacspeak-maths))
+    (delete-process (emacspeak-maths-server-process emacspeak-maths)))
+  (message "Shutdown Maths server and client."))
 
 ;;}}}
 (provide 'emacspeak-maths)

;;}}}
;;{{{ Setup:


(defvar emacspeak-maths-server-program
  (expand-file-name "math-server.js"
                    (file-name-directory (or load-file-name default-directory)))
  "NodeJS implementation of math-server.")

(defun emacspeak-maths-start ()
  "Start Node math-server, and connect to it."
  (declare (special emacspeak-maths-inferior-program
                    emacspeak-maths emacspeak-maths-server-program))
  (let* ((server (make-comint "Maths" emacspeak-maths-inferior-program))
         (client (open-network-stream "math" "math" "localhost" 5000)))
    (setf emacspeak-maths
          (make-emacspeak-maths
           :output (get-buffer-create "*Spoken Math*")

  server-buffer ; comint buffer
  server-process ; node process handle
  client-buffer ; network socket stream
  client-process ; network connection
  output ; where output is displayed
  results
  )
