title: Close popup window if user log out in angular
body: <p>In my application, has a page user can open an popup window. When user click logout it must close popup window.
  I use a static variable for store popup window variable in <code>Global.ts</code> class</p>
  
  <pre><code>public static QUICKTREND : any;
  </code></pre>
  
  <p>In function to open popup window, i stored it</p>
  
  <pre><code>this.quickWin = window.open(URL, 'QuickTrend', 'width=' + w + ', 
  height=' + h + ', left=' + x + ', top=' + y + ', location=no'+ ', status=no'); 
   Constants.QUICKTREND = this.quickWin;
  </code></pre>
  
  <p>In logout() function I get popup window and close</p>
  
  <pre><code>if(!isNullOrUndefined(Constants.QUICKTREND)){
         let currentIframe = Constants.QUICKTREND;
         currentIframe.close();
   }
  </code></pre>
  
  <p><strong>It worked correct if I did not refresh page.</strong> </p>
  
  <p>But when I refresh page, variable QUICKTREND reset to undefined.</p>
  
  <p>I searched solution to keep variable if page is refresh, only solution to save to localStorage or sessionStorage. But this way, I can not save popup window object because it is DOM object, <code>Converting circular structure to JSON</code> error show.</p>
  
  <pre><code>localStorage.setItem("currentIframe", this.quickWin);
  </code></pre>
  
  <p>Is it possible to save popup window to localStorage?</p>
  
  <p>How can I close popup window when I logout if page is refresh?</p>