#### 3.5.2.2 Quitting the Program ¶

Following commands quit the program:

Mail command: quit ¶

  Terminates the session. The messages, marked with `delete` are removed. The messages in state ‘`read`’ and ‘`saved`’ are processed depending on the mailbox they are in.

  If `mail` was operating on the user system mailbox, all messages in state ‘`read`’ are preserved. The location where they are preserved is determined by the `hold` variable. If it is not set (the default), the messages are moved to the user’s `mbox`. If `hold` is set, the messages are held in the system mailbox instead.

  The default behavior for ‘`saved`’ messages is to remove them from the system mailbox. If, however, the `keepsave` variable is set, they are preserved using the same rules as for ‘`read`’ messages.

  For non-system mailboxes, both ‘`read`’ and ‘`saved`’ messages are retained in their current location.

  The same rules are followed when the mailbox is switched using the `file` command.

  The program exits to the shell, unless saving the mailbox fails, in which case user can escape with the exit command.

Mail command: exit ¶
Mail command: ex ¶
Mail command: xit ¶

  Program exits to the shell without modifying the mailbox it operates upon.

Typing EOF (‘`C-D`’) alone is equivalent to ‘`quit`’.