void BrowserProcessImpl::EndSession()
{
    // Mark all the profiles as clean.
    ProfileManager* pm = profile_manager();
    std::vector<Profile*> profiles(pm->GetLoadedProfiles());
    for(size_t i=0; i<profiles.size(); ++i)
    {
        profiles[i]->MarkAsCleanShutdown();
    }

    // Tell the metrics service it was cleanly shutdown.
    //MetricsService* metrics = g_browser_process->metrics_service();
    //if(metrics && local_state())
    //{
    //    metrics->RecordStartOfSessionEnd();

    //    // MetricsService lazily writes to prefs, force it to write now.
    //    local_state()->SavePersistentPrefs();
    //}

    // We must write that the profile and metrics service shutdown cleanly,
    // otherwise on startup we'll think we crashed. So we block until done and
    // then proceed with normal shutdown.
    //BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
    //    NewRunnableFunction(PostQuit, MessageLoop::current()));
    MessageLoop::current()->Run();
}