To terminate a web worker, and free browser/computer resources, use the terminate() method:
w.terminate();