          (port (process-contact p :service)))
     (when p (delete-process p))
     (unless port
-      (error "Could not retrive unused localhost port"))
+      (error "Could not retrieve unused localhost port"))
     port))
 
 (defun ycmd--exit-code-as-string (code)

                         (parser 'buffer-string)
                         (type "POST")
                         (params nil)
                         (sync nil))
  "Send an asynchronous HTTP request to the ycmd server.

This starts the server if necessary.

ycmd server to stop.  If the ycmd server is still running after a
timeout specified by `ycmd-delete-process-delay', then kill the
process with `delete-process'."
  (let ((start-time (float-time)))
    (ycmd--request
     "/shutdown" nil
     :parser 'json-read :sync t :timeout 0.1)
    (while (and (ycmd-running?)
                (> ycmd-delete-process-delay
                   (- (float-time) start-time)))
      (sit-for 0.05))
    (ignore-errors
      (delete-process ycmd--server-process-name))))

(defun ycmd-running? ()
  "Return t if a ycmd server is already running."
