Worker.terminate()

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

myWorker.terminate();

Parameters

None.

Returns

Void.

Example

The following code snippet shows creation of a Worker object using the Worker() constructor, which is then immediately terminated.

var myWorker = new Worker('worker.js');

myWorker.terminate();

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
terminate
4
12
3.5
10
10.6
4
4
18
4
11
5
1.0

See also

The Worker interface it belongs to.

© 2005–2021 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