% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/unexported.R
\name{dw_dev_off}
\alias{dw_dev_off}
\title{Close a graphics device only if it is actually open}
\usage{
dw_dev_off(which = NULL)
}
\arguments{
\item{which}{(\code{integer}). Device number to close. Defaults to the current device.}
}
\value{
Invisibly, \code{TRUE} if a device was closed and \code{FALSE} otherwise.
}
\description{
Defensive wrapper around \code{dev.off()}. Plotting helpers occasionally close the
  device they were handed, and a bare \code{dev.off()} with nothing but the null device left
  fails with \dQuote{cannot shut down device 1 (the null device)}. This closes the requested
  device when it is still in \code{dev.list()} and is a silent no-op otherwise, so cleanup code
  and \code{on.exit()} handlers cannot error.
}
\keyword{internal}
