Added a threaded worker slave and safety check for closeEvent when this thread is still running.