The server library calls the Exit function in the OLESERVERVTBL structure when the server must quit. The server library calls the Release function to inform the server that it is safe to quit; the server does not necessarily stop when the library calls Release.
The server must exit when it is invisible and the library calls Release. (The only exception is when an application supports multiple servers; in this case, an invisible server is sometimes not revocable when the library calls Release.) If the server has no open documents and it was started with the /Embedding option (indicating that it was started by a client application), the server should exit when the library calls the Release function. If the user explicitly loads a document into a single-instance (MDI) server, however, the server should not exit when the library calls Release.
When the user closes a server that has edited an embedded object without updating changes to the client application, the server should display a message asking whether to save the changes. If the user chooses to save the changes, the server should send the OLE_CLOSED notification and call the OleRevokeServerDoc function. (Because sending OLE_CLOSED prompts the server library to send data to the client library, it is not necessary to send OLE_CHANGED or OLE_SAVED. If the user chooses not to save the changes, the server should simply call the OleRevokeServerDoc function (without sending OLE_CLOSED).
A server can use the OleRevokeObject function to revoke a client's access to an object—for example, if the user destroys the object. Similarly, the OleRevokeServerDoc function revokes a client's access to a document. (Because OleRevokeServerDoc revokes a client's access to all objects in a document, an application that uses OleRevokeServerDoc does not need to call the OleRevokeObject function for objects in that document.) To terminate all conversations with client applications, the server can call the OleRevokeServer function. These functions inform the server library that the specified items are no longer available.
A server application can receive OLE_WAIT_FOR_RELEASE—for example, the OleRevokeServerDoc function can return this value. Although a server can enter a message-dispatch loop and wait for the library to call the server's Release function, servers should never enter message-dispatch loops inside any of the server-supplied functions that are called by the server library.
The client application should not instruct the server to close the document or exit when the server is editing a linked object, unless the server is updating the link without displaying the object to the user. Because a linked object exists independently of the client, the user controls saving and closing the document by using the server application.
If a server application owns the clipboard when it closes, it should make sure that the data on the clipboard is complete and in the correct order. For example, any Native data should be accompanied by the OwnerLink format.