worker.terminate()immediately stops a dedicated Worker from the main thread (MDN). The worker does not get a chance to finish work or run cleanup — it is halted at once.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call worker.terminate. Start with this line.
JavaScript
worker.terminate()
Call
What it does
worker.terminate()
Primary signature.
worker.terminate(...)
Call with the arguments your case needs.
Built into the browser. Call worker.terminate(...) on a Worker — no import required.
Library declarations
JavaScript
worker.terminate()
Parameters
This member has no parameters beyond those shown in the signature.
Unlike terminate(), the worker chose when to stop.
Use terminate() when main must cut the thread off immediately.
Compatibility
Browser Support
Worker.terminate() is Baseline Widely available (MDN: since July 2015). Available in Web Workers except Service Workers — not in Node.js, Bun, or Deno (use worker_threads there).
✓ Baseline · Widely available
Worker.terminate()
Immediately stop a dedicated worker from the main thread. No parameters. Safe everyday Web Worker API.
100%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
terminateExcellent
Bottom line: Safe for production dedicated workers. Prefer self.close() when the worker should finish cleanup first. See the MDN terminate reference.
Frequently Asked Questions
It immediately stops a dedicated Worker from the main thread. The worker does not get a chance to finish current work or run cleanup—it is halted at once.
No. MDN marks Worker.terminate() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is available in Web Workers except Service Workers.
No graceful shutdown from terminate(). If you need the worker to finish or clean up, send a message and let it call self.close() (or SharedWorkerGlobalScope.close() for shared workers) instead.
No. After terminate(), that Worker instance is done. Create a new Worker() if you need another background script.
Yes when you created the worker from URL.createObjectURL(blob). Call URL.revokeObjectURL(url) after terminate() so the blob can be garbage-collected.
postMessage after terminate will not get a normal worker reply. Treat the worker as gone and discard pending expectations.