Fixed an issue related to a lock when closing the serial port.

Signed-off-by: Ruben Moral <Ruben.Moral@digi.com>