solve problem when quitting serial port