If you set the worker variable to undefined, after it has been terminated, you can reuse the code:
w = undefined;
Read Article https://horje.com/learn/1434/reference