The close()
method is visible inside the worker’s scope.
The terminate()
method is a part of the worker object’s interface and can be called “from the outside”.
If you create a worker in your main script and want to stop it from that script you should call the terminate()
on the worker object. If you want to stop the worker from the worker code (for example as a response to an external message) you should call the close()
method.
Source: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Terminating_a_worker