title: Protractor Session ID issues with this driver does not have a valid session ID and may no longer be used
body: <p><br />
  I am new at using Protractor and just started using it a month or so ago. I am using Protractor 2.5.1 and cucumber NOT Jasmine; I have been running into session ID issues with my tests lately. <br /><br /> Sometimes my tests pass and sometimes they fail with this error: <code>(This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.)</code>
  The only suggestion I found online was that <code>this happens when you do not use callback()</code> but that doesn't seem to be true as I used callbacks in my cucumber tests and that didn't prevent it. <br /><code>Another solution suggested was to set a max width to the window size, that didn't cut it either</code>.
  <br><br />
  Here's what I tried: </p>
  
  <ol>
  <li>I know that the driver wouldn't quit if there was one more step
  after the last one, like a 'stall or no-op' so I added one more step
  just to give time to the driver to complete last operation but that
  didn't work.</li>
  <li><p>I use callbacks like this</p>
  
  <blockquote>
  <pre><code>&gt; this.When(/^I "([^"]*)" and do something with this"([^"]*)"$/,
  &gt; function (action, result, callback) {
  &gt;     return app.takeAction(action).then(function (res) {
  &gt;       return res === result; //passed in up there   
  &gt;     }).then(callback) //notice callback here as suggested 
                         //to avoid this invalid session id issue 
  &gt;       .then(null, function () {     //handle error here     
  &gt;         console.log('An error occured');
  &gt;       });   });
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li><p>Notice the processing pipiline in code right above, if the callback throws an error for whatever reason, it'll be caught by the last error handler. </p></li>
  <li><p>Because you have to login to our application, I make sure to log you off before every feature file i.e test. This should destroy previous cookie/session but all of these attempts were unseccussful at resolving this problem.</p></li>
  </ol></li>
  </ol>
  
  <blockquote>
    <p>Oh all my tests run successfully, but then at the very end, fail with
    that invalid session id error.
    Error: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
        at checkHasNotQuit (C:\</p>
  </blockquote>
  
  <p><br />
  Has anyone run into this issue and what was your fix to it? Any help would be greatly appreciated.</p>
  
  <p>BTW here's my config file: </p>
  
  <pre><code>&gt; exports.config = {   framework: 'cucumber',   capabilities: {
  &gt;     'browserName': 'chrome',
  &gt;     loggingPrefs: {
  &gt;       driver: 'DEBUG',
  &gt;       server: 'INFO',
  &gt;       browser: 'ALL'
  &gt;     }   },
  &gt; 
  &gt;   resultJsonOutputFile: conf.paths.e2e + '/out/test-report.json',  
  &gt; specs: [
  &gt;     conf.paths.e2e + '/**/*.feature'   ],
  &gt; 
  &gt; selenium server   baseUrl: 'http://localhost:3000/application/',
  &gt; 
  &gt;   onPrepare: function() {
  &gt;     console.log('Getting:'+exports.config.baseUrl);
  &gt;     browser.get(exports.config.baseUrl);
  &gt;     browser.driver.manage().window().maximize();
  &gt;     browser.manage().timeouts().setScriptTimeout(15000);
  &gt; 
  &gt;     var tmpDir = path.resolve(__dirname, './e2e/screenshots');
  &gt;     console.log('Clearing tmp dir: ' + tmpDir);
  &gt;     rimraf(tmpDir, function(error) {
  &gt;       if (error) {
  &gt;         console.error('Error clearing tmp dir: ', error)
  &gt;       }
  &gt;     });   },
  &gt; 
  &gt;   cucumberOpts: {
  &gt;     require: conf.paths.e2e + '/steps/**/*Steps.js',
  &gt;     tags: [ '~@wip', '~@manual' ],
  &gt;     format: 'pretty'   } };
  </code></pre>