title: Excel process won't quit after COM automation
body: <p>I need to automate a specific version of Excel (2003), independent of the default version installed on the target machine. For this purpose, I am using the following steps:</p>
  
  <ul>
  <li>launch Excel by supplying the desired executable to <em>CreateProcess</em></li>
  <li>find the main and accessible window with <em>EnumWindows</em> and <em>EnumChildWindows</em></li>
  <li>use <em>AccessibleObjectFromWindow</em> to get an object from the Excel object model</li>
  <li>do the automation stuff through COM smart pointers</li>
  </ul>
  
  <p>This all works fine, but the Excel process will not terminate after a call to <em>Quit</em> on the <em>ExcelApplication</em> object. The same setup with Word works as intended, and the process terminates as it should. Any idea about why Excel behaves differently would be much appreciated.</p>
  
  <p>I've read about similar problems when automating Excel from .NET, where dangling COM references are the reason. However, if that is the reason in my C++ case as well, I don't understand why. Even if I do nothing except <em>Quit</em>, the process still remains alive:</p>
  
  <pre><code>/* create process, get handle to accessible Excel window */
  
  Excel11::_ApplicationPtr excelApplication;
  
  try
  {
    Excel11::WindowPtr::Interface* pInterface;
    if ( ::AccessibleObjectFromWindow( hwndExcelAccessible, OBJID_NATIVEOM, IID_IDispatch, reinterpret_cast&lt; void** &gt;( &amp;pInterface ) ) == S_OK )
    {
      excelApplication = pInterface-&gt;Application;
      pInterface-&gt;Release();
    }
  }
  catch ( _com_error&amp; e ) { /* omitted */ }
  
  excelApplication-&gt;Quit();
  </code></pre>