Application Shutdown Changes in Outlook 2007 Service Pack 2 Beta

As part of the performance improvements we’ve made for Outlook 2007 SP2 beta, we’ve changed the way Outlook manages the lifecycle of the application. In the past, Outlook followed the best practices for Component Object Model (COM) servers and allowed clients of the Outlook server to control the lifecycle of Outlook. This caused a significant end-user side effect: often the user could not close Outlook because of lingering external references. This is confusing and frustrating for our users, and many users would often use Task Manager to terminate the Outlook process.

As a result of strong and long-standing customer feedback about the need to close Outlook and have Outlook stop running, Service Pack 2 changes the way Outlook closes, ensuring that the user’s intent to close Outlook is respected. These changes mean the way the Outlook COM server shuts down has changed significantly, which may impact solutions using the Outlook object model outside of the Outlook process.

Impact for Add-ins: None

If you’ve written an in-process add-in for Outlook this change does not affect you. The lifecycle of in-process add-ins and in-process COM references in Outlook 2007 has always been the same as the lifecycle of the application. When the user closes the last Outlook window and Outlook starts to shut down, add-ins are disconnected and references are released.

Add-ins can use the Quit event on the Application object to determine when Outlook will be closing down. After the Quit event is raised, add-ins will have their OnDisconnection method called, and then the add-in and Outlook will close.

Impact for Cross Process Solutions

Before Outlook 2007 SP2, Outlook would check for external (out of process) references on the COM Server objects and wait for those references to be released before Outlook would close. This would enable solutions that were depending on Outlook data to keep Outlook running until the references were released. This is common behavior for COM servers, but is unexpected behavior for end users, who expect that an application will close when they close the last window of the application (or at least reasonably soon after they close the last window).

Starting with Outlook 2007 Service Pack 2, Outlook will ignore external COM references when determining if Outlook should exit. When a user closes the last Outlook window, Outlook will start exiting the process: this involves raising the Quit event on the Application object, disconnect all add-ins, disconnecting external references, persisting in-memory changes to the disk, and then exiting. All external COM references will be disconnected immediately after the Quit event is raised on the Application object.

Because of the way COM works, when Outlook releases the external references, those objects become disconnected objects in cross process solutions. When a solution attempts to use the disconnected reference, an error will result from any call to the object (RPC_E_DISCONNECTED). Solutions that are not designed to handle this error may crash or otherwise misbehave. This will occur any time a solution attempts to use an object reference after Outlook has closed.

To work correctly with the new behavior in Outlook, your solution should listen for the Quit event on the Application object. When that event is raised, stop any work in progress using Outlook data, and release all Outlook references. Any remaining references after the solution returns from the Quit event will be disconnected.

While handling the Quit event, a solution should return from the event as quickly as possible. While a solution is working in the Quit event, Outlook may appear hung to the user and the operating system and the user may forcibly terminate Outlook instead of waiting for it to finish closing.

If your solution needs to access data from Outlook after the process has shutdown, it can do so by starting the process up again in UI-less mode by calling CoCreateInstance(). However, you should attempt to design your solution such that data from Outlook is only collected while Outlook is running. I’ll be blogging about an example of how to design a solution that works this way in an upcoming blog post.

Special Cases

While the text above describes the default, we realize that there are customers and solutions which will be negatively impacted by this change until the solution can be updated. To restore the old behavior, administrators can set a registry key to force Outlook to wait for all external references to be released before closing.

This registry key applies to Outlook 2007 SP2 beta, the registry key may change for the final release of SP2.


We’ve also done work to ensure that when a solution uses CoCreateInstance and Outlook isn’t running, the right things happen. In those cases, Outlook will remain running in “headless mode” without any visible user interface. If the user launches Outlook, a new Outlook window will appear in the same session Outlook was already using. If the user closes that window, even though the process was started by a solution, Outlook will exit in the same manner as it would if the application was started by the user.


As part of a larger overall performance improvement effort in Outlook 2007 Service Pack 2, the team has invested a significant amount of time to improve the experience around closing Outlook. We’ve also made changes to ensure that Outlook boots faster and is more responsive all around.

I’m interested in your feedback on this new shutdown logic, and any thoughts or questions about how we can continue to improve this experience in the next Outlook release. Please leave a comment on this post and let me know what you have to say.

Comments (21)

  1. Ryan posted an article about some changes we’re making in Outlook 2007 SP2. The gist is we’re changing

  2. Steve asked me to link to a post from Ryan Gregg detailing some changes in Outlook 2007 SP 2 Beta. 

  3. Ryan Gregg has a post out there that is worth a read for anyone who is automating Outlook out of process.

  4. I’m really looking forward to this behavior, since it’s annoying that I have to close Windows Live Messenger in order to backup my PST files because it keeps Outlook open.

  5. I’ve been waiting for this feature (as I’m sure most have) since Outlook was introduced.  When you

  6. Ryan Gregg, a Program Manager on the dev team with Outlook, has released details on some important changes

  7. Lev says:

    Correct me if I’m wrong, but the shutdown behavior changes for every version of Outlook.

    If I remember right, Outlook 2000 had trouble shutting down no matter what.

    Outlook 2002 then always shutdown ignoring the reference count.

    Outlook 2003 finally appeared to work Right as the COM server is supposed to work – keeping track of external references.

    Finally, we go back to behavior, where the ref. count is ignored.

    Looking forward to the next change 🙂


  8. Eric Berger says:

    Ad Hoc violation of COM "rules/contract" standards will be confusing and lead to difficulties in development/maintenance.  Why not have "hidden" Outlook COM servers advise users which applications are connected to them and give users an opportunity to gracefully close the apps without abnormally terminating the Outlook server?

  9. Flemming Riis says:

    Any updates on OST performance on SSD drives in regards to many small random writes

  10. rgregg says:

    Flemming: We’ve done a lot of work on performance as a whole for SP2, and will be announcing more details about the specifics of how performance has been improved closer to the release date for Service Pack 2.

  11. Jim says:

    If I’m reading this correctly, Outlook SP2 beta will resolve the insidious problem of following a proper shutdown of Outlook 2007 you get the message that Outlook did not close properly, etc. This topic has been talked about in the forums forever with all kinds of conflicting advice.

  12. rgregg says:

    Jim: You should see incidents of the data validation check drop significantly with SP2. We’ve done work to reduce the chance that Outlook and other MAPI clients have to leave the data file in a state that would require validation.

  13. Henry Gusakovsky says:

    I’d like to know about MAPI subsystem shutdown changes.

    The current version does not call IMsgStore::StoreLogoff, IMSLogon::Logoff and release MSLogon object if there is some MAPI Objects other than IMsgStore leaked. That maked PST provider to recheck PST file every start of Outlook.

  14. Andy says:


    1) Outlook will close when I tell it to and not when some bozo with lazy programming habits deigns it suitable.

    2) This bozo won’t cause me to loose all my favourite folder settings either

    3) Maybe other stuff too 🙂

  15. IT Worker Let Spammers Into Ex-employer's Servers Considerations for virtualizing Exchange 2007 mailbox

  16. Darren says:

    Do you know what the effect of this will be with Windows Mobile device and active synch.  Will this keep re-enabling the process when active synch starts synching the next time.

  17. Anil Sharma says:


    How I create a Setupt that support MS SMS (Microsoft Systems Management Server) for silent installations .


  18. Any ETA on SP2?

    Thanks in advance.

  19. Jim says:

    Excellent! Thank you! Thank you! Thank you!

    Outlook not shutting down keeps my backup from archiving my inbox–very bad. May it soon finally work.

  20. markovich says:

    1) Outlook will close when I tell it to and not when some bozo with lazy programming habits deigns it suitable.

    2) This bozo won’t cause me to loose all my favourite folder settings either

    3) Maybe other stuff too 🙂

  21. I previously wrote about some changes the development team had in mind for Outlook 2007 SP2 in the area

Skip to main content