Protect all usb writes reads and unplugs with a mutex lock and check libusb release has succeeded before proceeding with a libusb close.