This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers, except for Service 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.
terminate()
None.
None (undefined).
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 Worker instance using the DedicatedWorkerGlobalScope.close() or SharedWorkerGlobalScope.close() methods.
| Specification |
|---|
| HTML> # dom-worker-terminate-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
terminate |
2 | 12 | 3.5 | 10.6 | 4 | 18 | 4 | 11 | 5 | 1.0 | 4.4 | 5 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate