How to safely close Google Chrome programmatically
See the question and my original answer on StackOverflowYou could use the little known UI Automation API, like this:
static void CloseAllChromeBrowsers()
{
foreach (Process process in Process.GetProcessesByName("chrome"))
{
if (process.MainWindowHandle == IntPtr.Zero) // some have no UI
continue;
AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);
if (element != null)
{
((WindowPattern)element.GetCurrentPattern(WindowPattern.Pattern)).Close();
}
}
}