Before the end of the program, always call plend to close any output plot files and to free up resources. For devices that have separate graphics and text modes, plend resets the device to text mode.
plend