title: Electron session webrequest function in a renderer window that has been closed or released
body: <p>From main window i am using this code to open a window on click</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>pwin = new BrowserWindow({
    width: 355,
    height: 250
  })
  pwin.loadURL(`file://${__dirname}/players/jwplayer.html`);
  // pwin.setMenu(null)
  pwin.webContents.on('did-finish-load', () =&gt; {
    pwin.webContents.send('link', link);
    pwin.webContents.send('name', title);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>on the new window i have a code to modify request headers</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>session.defaultSession.webRequest.onBeforeSendHeaders(['*://*./*'], (details, callback) =&gt; {
    if (details.url.indexOf('okaystreamz') &gt; -1) {
      details.requestHeaders['User-Agent'] = 'tvingoplus@livetv.tvingo1Z!2018';
    }
  
    callback({
      cancel: false,
      requestHeaders: details.requestHeaders
    })
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I am opening the pwin first time, its working.
  When I close it and open it again, I get this error</p>
  
  <p>"Attempting to call a function in a renderer window that has been closed or released."</p>
  
  <p>Any help will be appreciated</p>