Updates for compatibility with contemporary version of qtserialport, plus try and close the serial port before quitting