Fixed bug where closing the device connection does not actually close the device.