static bool ConsoleEventCallback(int eventType) { if (eventType == 2) { List<Process> pList = Process.GetProcessesByName("chrome").ToList(); try { pList.ForEach(i => i.Kill()); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return false; } private delegate bool ConsoleEventDelegate(int eventType); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add);