attemp to fix broken pipe by ensuring usb closed after exiting code