fixed serial port closing with Thread