* Electron version: 1.4.14
* Operating system: Windows

Hi!
I faced with issue described in this two comments: 
https://github.com/electron/electron/issues/6388#issuecomment-236498471
https://github.com/electron/electron/issues/6388#issuecomment-244483403
The main issue is fixed, but the session is lost if the app is closed immediately after login and setting the cookie.

### Expected behavior
Cookie should be saved.

### Actual behavior
When the app is closed after less then 10-15 seconds a cookie is set, it is not saved when the app is reopened. 

atom/browser/api/atom_api_cookies.cc
if (net::cookie_util::DomainIsHostOnly(filter))
    filter.insert(0, ".");
  std::string sub_domain(domain);
  
  if (!net::cookie_util::DomainIsHostOnly(sub_domain))
    sub_domain = sub_domain.substr(1);
  
  for (sub_domain.insert(0, "."); sub_domain.length() >= filter.length();) {
    if (sub_domain == filter)
      return true;
    const size_t next_dot = sub_domain.find('.', 1);  
    sub_domain.erase(0, next_dot);
  }
  return false;
}
bool MatchesCookie(const base::DictionaryValue* filter,