I had the same problem and found that within a long plotting function I had made, was hidden accidentally dev.off() and this kept stopping dev.off() from later occurring where I actually wanted