\Header{quit}{Terminate an R Session}
\alias{q}{quit}
\alias{.Last}{quit}
\keyword{environment}{quit}
\begin{Usage}
\begin{verbatim}
quit(save="ask")
   q(save="ask")
.Last <- function(x) { ...... }
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{save}] a character string indicating whether the
environment (workspace) should be saved.
\end{ldescription}
\end{Arguments}
\begin{Description}
The function \texttt{quit} or its alias \texttt{q} terminate the current \R
session.
\texttt{save} must be one of \texttt{"no"}, \texttt{"yes"},
or \texttt{"ask"}.
In the first case the workspace is not saved, in the second
it is saved and in the third the user is prompted and can also decide
\emph{not} to quit.

Immediately \emph{before} terminating, the function \texttt{.Last()} is
executed if it exists.\end{Description}
\begin{SeeAlso}
\texttt{\Link{.First}} for setting things on startup.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
.Last <- function() {
  cat("Now printing  PostScript graphic:\n")
  system("lpr Rplots.ps")
  cat("bye bye...\n")
}
## Not really:  quit("yes")
\end{ExampleCode}
\end{Examples}

