private void CloseAll() { //---now find all the instances of IE that are running. You can use this for any program! Process[] theProcesses = System.Diagnostics.Process.GetProcessesByName("Iexplore"); //'---cycle through them and find the one where my search string shows up in the IE title bar //'---I am using the IndexOf function. It searches a string within a string and returns an //' integer which indicates the first position in the string being searched where it found a match //'If the value is >= 0 then it found it (zero based). foreach (Process currentProcess in theProcesses) { int position = currentProcess.MainWindowTitle.IndexOf(this.SearchString); if (position >= 0 ) currentProcess.Kill(); } Application.Exit(); }