Thank you for your answer I ran dev.off() many times but it didn't work. after each dev.off says this:
function (which = dev.cur())
{
if (which == 1)
stop("cannot shut down device 1 (the null device)")
.External(C_devoff, as.integer(which))
dev.cur()
}
<bytecode: 0x209f8be0>
<environment: namespace:grDevices>