Added code to cleanly close out serial port when thread is done