Added shutdown hook for closing serial ports on shutdown