We let the thread finish before stopping it, by calling waitForThread().

This prevent the application to crash when quitting, on OS X. It does not solve the issue on Windows though.