Changed the order of closing to closing "reader" before the sending the "term" process command, hopefully will prevent deadlock when reading a line and the "term" cmd is sent