diff --git a/openhantek/src/main.cpp b/openhantek/src/main.cpp index 8c2513c..f5f3b5a 100644 --- a/openhantek/src/main.cpp +++ b/openhantek/src/main.cpp @@ -205,7 +205,10 @@ int main(int argc, char *argv[]) { postProcessingThread.quit(); postProcessingThread.wait(10000); - if (context && device != nullptr) { libusb_exit(context); } + if (context && device != nullptr) { + device.reset(); // causes libusb_close(), which must be called before libusb_exit() + libusb_exit(context); + } return res; }