tools: Use shutdown hook to make sure serial port is closed when patserdow exits.