title: Process CloseMainWindow() function doesn't work
body: <p>I have a test method which requires Internet Explorer to be opened and closed numerous times during the test. I have been creating a process like this: </p>
  
  <blockquote>
    <p>Process process = Process.Start(...);</p>
  </blockquote>
  
  <p>And closing it like this: </p>
  
  <blockquote>
    <p>process.CloseMainWindow();</p>
  </blockquote>
  
  <p>However, I have found that I can only call this method once, otherwise I get the error message, "Process has exited, so the requested information is not available". </p>
  
  <p>Once I have closed the process, I would then re-launch Internet Explorer. e.g. </p>
  
  <blockquote>
    <p>process = Process.Start(...);</p>
  </blockquote>
  
  <p>But this didn't work. I also tried nulling the Process variable before calling the Process.Start() method, but this didn't work. </p>
  
  <p>I also tried using process.Kill(), but this caused problems too. </p>
  
  <p>What is the correct way to do this? </p>
  
  <p>UPDATE: Code</p>
  
  <pre><code>Process Browser;
  
  [TestInitialize]
  public void TestSetup()
  {
      Browser = TestBase.LaunchBrowser();
  
      ...
  
      Browser.WaitForInputIdle();
      Browser.CloseMainWindow();
  
      Browser = null
      Browser = Process.Start("IExplore.exe", ...);
  }
  
  [TestMethod]
  public void MyTest()
  {
     // do things
     Browser.Kill();
     Browser = Process.Start("IExplore", "www.adifferentwebpage");
  }
  
  [TestCleanup]
  public void TestCleanup
  {
     Browser.Kill();
  }
  </code></pre>