When the user closes the document containing your part, or when your part is deleted from its containing part, OpenDoc calls your part's ReleaseAll method, followed by its somUninit method. (If, when closing a document, the user specifies that changes be saved, your part's Externalize method is called before ReleaseAll.)
The ReleaseAll method is inherited from ODPersistentObject. Its purpose is to ensure that all your part's references to other objects and ownership of shared resources are relinquished before your part is itself deleted from memory. As a minimum, your override of the ReleaseAll method should:
Your part should not write itself to storage from within its ReleaseAll method. Your part's Release method, inherited from ODRefCntObject, is called under different circumstances from ReleaseAll. For information on implementing a Release method, see "Reference-Counted Objects".
After it completes ReleaseAll, your part receives no subsequent method calls except to its System Object Model (SOM) object destructor somUninit. The somUninit method is inherited from the somObject class of SOM; when you subclass ODPart, you must override somUninit.
Your somUninit method should dispose of any storage created for your part object by the somInit method and any other storage related to additional instance variables of your part initialized during execution. In this method, do not perform any tasks that could fail.