Stop/Wait a QML WorkerScript

My app use a lot of WorkerScript to process large amount of data. If a WorkerScript is running and the user exit the app, this will cause the app stuck on the background (or became a zombie process in Linux). So is there any way to stop/terminate a running workerscript or wait for it to execute finish (like QThread::wait()) so that I can stop/wait it when the app is exiting?