Cleaned up and fixed dangling pointer if the SerialLink thread ended, and the port wasn't open