Once you are done with a worker you should terminate it. This helps to free up resources for other applications on the user’s computer.
// Terminate a worker from your application. worker.terminate();
terminate method is not available for service workers. It will be terminated when not in use, and restarted when it's next needed.
// Have a worker terminate itself. self.close();