When a client calls IMAPISession::Logoff to end the session and shut down all active service providers, MAPI in turn calls:
Each of these methods have similar implementations. The main tasks that a logoff method performs are:
When your logoff method returns, MAPI calls:
If your provider is a message store, a client call to IMsgStore::StoreLogoff will also initiate the shutdown process. StoreLogoff shuts down one particular message store provider and has no affect on the session. Only a message store provider can be shut down with this method; there is no explicit way for shutting down a particular address book or transport provider. For information about how to respond to a StoreLogoff call, see Shutting Down a Message Store Provider.
Your provider's DLL will be unloaded when MAPI calls the Win32 API function FreeLibrary, a call that is made after the last active client has called MAPIUninitialize. By this time, your service provider will have finished shutting down.