title: Event when chrome popup is closed
body: <p>I need to listen to Chrome popup's closing event.
  I tried listening to <code>onDisconnect</code> event as suggested <strong><a href="https://stackoverflow.com/questions/15798516/is-there-an-event-for-when-a-chrome-extension-popup-is-closed">here</a></strong>
  :</p>
  
  <p>background.js</p>
  
  <pre><code>  var port = chrome.runtime.connect({ name: "hello" });
    port.onDisconnect.addListener(function() {
      console.log("Disconnected");
    });
  </code></pre>
  
  <p>However, I get <code>Disconnected</code> every time I open the popup, not when I close it. Does anyone know why this is happening?</p>