`liece-command-own-freeze'.
        (liece-command-toggle-beep): Rename from `liece-dialogue-beep'.
 
+2000-09-22   Daiki Ueno  <ueno@unixuser.org>
+
+       * liece-handle.el (liece-handle-kill-message): Call
+       `liece-close-server' instead of `liece-clear-system'.
+
+       * liece-commands.el: Don't autoload `liece-window-configuration-pop'.
+       (liece-command-quit): Just send quit.
+
+       * liece.el (liece-close-server): Run `liece-exit-hook'; abolish
+       argument `quit-string'.
+
+       * liece-filter.el (liece-sentinel): Call `liece-close-server'.
+
 2000-09-20   Daiki Ueno  <ueno@unixuser.org>
 
        * liece-compat.el: Require `wid-edit'.
 
 (require 'liece-minibuf)
 
 (autoload 'liece-dcc-chat-send "liece-dcc")
-(autoload 'liece-window-configuration-pop "liece-window")
 
 (autoload 'liece-command-ctcp-version "liece-ctcp" nil t)
 (autoload 'liece-command-ctcp-userinfo "liece-ctcp" nil t)
           (if arg (read-string (_ "Signoff message: "))
             (or liece-signoff-message
                 (product-name (product-find 'liece-version))))))
-      (liece-close-server quit-string))
-    (liece-clear-system)
-    (if liece-save-variables-are-dirty
-       (liece-command-save-vars))
-    (if (interactive-p)
-       (liece-window-configuration-pop))
-    (run-hooks 'liece-exit-hook)))
+      (if quit-string
+         (liece-send "QUIT :%s" quit-string)
+       (liece-send "QUIT")))))
 
 (defun liece-command-generic (message)
   "Enter a generic IRC MESSAGE, which is sent to the server.
 
        (liece-sentinel-error proc status)
       (liece-message (_ "Connection closed. (%s)")
                      (substring status 0 (1- (length status)))))
-    (liece-clear-system))
+    (liece-close-server))
    (liece-reconnect-with-password
     (liece))
    (t
 
     (liece-insert-info (append liece-D-buffer liece-O-buffer)
                        (format "You were killed by %s. (Path: %s. RIP)\n"
                                prefix path)))
-  (liece-clear-system))
+  (liece-close-server))
 
 (defun* liece-handle-join-message (prefix rest)
   (let (flag (xnick prefix) (nick prefix) (chnl rest))
 
     "Mapping from keywords to default values.
 All keywords that can be used must be listed here."))
 
-(defadvice save-buffers-kill-emacs
-  (before liece-save-buffers-kill-emacs activate)
-  "Prompt user to quit IRC explicitly."
-  (run-hooks 'liece-before-kill-emacs-hook) )
-
-(add-hook 'liece-before-kill-emacs-hook 'liece-command-quit)
+(add-hook 'kill-emacs-hook 'liece-command-quit)
 
 (defvar liece-tmp-server-name nil "Temporaly server name.")
 (defvar liece-buffer-last-check-time nil)
        liece-server nil))
 
 ;;;###liece-autoload
-(defun liece-close-server (&optional quit-string)
+(defun liece-close-server ()
   "Close chat server."
   (unwind-protect
       (progn
                   (eq 'liece-sentinel
                       (process-sentinel liece-server-process)))
          (set-process-sentinel liece-server-process nil))
-       ;; We cannot send QUIT command unless the process is running.
-       (when (liece-server-opened)
-         (if quit-string
-             (liece-send "QUIT :%s" quit-string)
-           (liece-send "QUIT"))))
-    (liece-close-server-internal)))
+       (if (liece-server-opened)
+           (liece-command-quit)))
+    (liece-close-server-internal)
+    ;; Save settings to the `~/.liece/init.el' file.
+    (if liece-save-variables-are-dirty
+       (liece-command-save-vars))
+    ;; Reset everything.
+    (liece-clear-system)
+    (liece-window-configuration-pop)
+    ;; Allow the user to do things after cleaning up.
+    (run-hooks 'liece-exit-hook)))
 
 (defmacro liece-server-keyword-bind (plist &rest body)
   "Return a `let' form that binds all variables in PLIST.