--- a/src/qtgui/idxthread.cpp
+++ b/src/qtgui/idxthread.cpp
@@ -51,6 +51,7 @@
 void stop_idxthread()
 {
     stopidxthread = 1;
-    while (idxthread.running())
-	sleep(1);
+    idxthread.wait();
 }
+
+