\Header{on.exit}{Function Exit Code}
\keyword{programming}{on.exit}
\begin{Description}\relax
\code{on.exit} records the expression given as its argument as needing
to be executed when the current function exits (either naturally or as
the result of an error). This is useful for resetting graphical
parameters or performing other cleanup actions.\end{Description}
\begin{Usage}
\begin{verbatim}
on.exit(expr, add = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{expr}] an expression to be executed.
\item[\code{add}] if TRUE, add \code{expr} to be executed after any previously
set expressions.
\end{ldescription}
\end{Arguments}
\begin{SeeAlso}\relax
\code{\Link{sys.on.exit}} to see the current expression.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
opar <- par(mai = c(1,1,1,1))
on.exit(par(opar))

\end{ExampleCode}
\end{Examples}

