This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/on.exit.html
on.exit {base}R Documentation

Function Exit Code

Description

on.exit records the expression given as its argument as needing to be executed when then current function exits (either naturally or as the result of an error). This is useful for resetting graphical parameters or performing other cleanup actions.

Usage

on.exit(expr)

Arguments

expr

an expression to be executed.

Examples

opar <- par(mai=c(1,1,1,1))
on.exit(par(opar))

[Package base version 0.60 ]