- WaitForSingleObject(self->thread, INFINITE);
- CloseHandle(self->thread);
+
+ /* 2 sec timeout, otherwise we would run to infinite loop some cases.. */
+ if (WaitForSingleObject(self->thread, 2000) == WAIT_TIMEOUT)
+ TerminateThread(self->thread, 0);
+