web api instance method
Worker: terminate() method
Available in workers
The terminate() method of the Worker interface immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is stopped at once.
Syntax
terminate()
Parameters
None.
Return value
None (undefined).
Examples
The following code snippet shows creation of a Worker object using the Worker() constructor, which is then immediately terminated.
const myWorker = new Worker("worker.js");
myWorker.terminate();
[!NOTE] DedicatedWorkers and SharedWorkers can also be stopped from the
Workerinstance using theclose()orclose()methods.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.