Fix unfinished thread when a device is disabled or on error.
Mostly due to a unlocked mutex but I used the occasion to improve serial connection