title: Unregistering/Removing a Service Worker
body: <p>I have a bad service worker that is no longer updating. I noticed the issue in Chrome first. I then put the following code in the index.html file and in the sw.js (service worker) file. For the most part it seems to be working fine. Firefox seems to be the only browser that is not removing the service worker. I used the article below to create the unregister script.</p>
  
  <p><a href="https://stackoverflow.com/questions/33704791/how-do-i-uninstall-a-service-worker">How do I uninstall a Service Worker?</a></p>
  
  <p>I have also used this article and code and got the same results.</p>
  
  <p><a href="https://stackoverflow.com/questions/33986976/how-can-i-remove-a-buggy-service-worker-or-implement-a-kill-switch">How can I remove a buggy service worker, or implement a &quot;kill switch&quot;?</a></p>
  
  <p>I am also receiving an error message for <code>getRegistrations()</code> saying it is undefined. Not sure how to fix that either.</p>
  
  <p>Help with both of these issues would be greatly appreciated.</p>
  
  <pre><code>&lt;script&gt;
  navigator.serviceWorker.getRegistrations().then(function(registrations) {
   for(let registration of registrations) {
    registration.unregister();
  } });&lt;/script&gt;
  </code></pre>