What you need to do is set the thread the test is running on into STA mode, and IE will close quickly.
[CodedUITest]
public class DoSomeAutomatedTesting
{
public DoSomeAutomatedTesting()
{
// Hey! Hey! Hey! We can't do no MTA!
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
}
[TestMethod]
public void MyTestMethod()
{
using(var ie = new IE())
{
ie.AutoClose = true;
ie.GoTo("http://www.google.com");
}
}
}
For those of you who aren't old farts who have done COM programming, this describes an STA http://msdn.microsoft.com/en-us/library/windows/desktop/ms680112(v=vs.85).aspx. Short story, STA is an old-school technique used by COM to preserve the viability of existing, tested, working, single-threaded code left over from the Windows 95 days in the scary, new-fangled world of preemptive multithreading.
Now, the CLR lives in what the COM calls the MTA. For those of us that don't live in 1998, you can think of the MTA as the real world, where things work the way they should. http://msdn.microsoft.com/en-us/library/windows/desktop/ms693421(v=vs.85).aspx
When some thread in the super-scary MTA wants to access something in an STA, the MTA thread is told to sit on the bench and wait its turn if the STA is currently being accessed by a different thread from the MTA. This basically means that sometimes, when the weather isn't right, you can get these wierd-o lags.