Use a timeout with usb handle events set to a nominal 200ms and wait for the polling thread to shut down before deinitialising libusb.