title: firestore unsubscribe finished event
body: <p>I am subscribed to a document in firestore, before I logout I want to unsubscribe otherwise it will throw an error since I am using firestore security rules and when the user is logged out and I didn't unsubscribe the access will be denied and it will throw an error.</p>
  
  <p>I tried the code below but still not working I still get errors from firestore security rules, so I introduced setInterval but it is taking too much time (in my test I have gone till 5s to be able to avoid the error)</p>
  
  <p>Do you have a better approach to avoid this issue, I mean is there an event that is fired once the unsubscription is done (I want to avoid setInterval with long time)?</p>
  
  <pre class="lang-js prettyprint-override"><code>var unsubscribe = db.collection('notifications').doc('docID').onSnapshot(
            function(doc) {
              // Do things
            })
  
  function logout () {
    unsubscribe(
      setTimeout(function() {
        firebase.auth().signOut().then(() =&gt; {
          // Redirect to home page
        });
      }, 600)
    )
  };
  </code></pre>