The both objects maintain threads where other COM objects can
be created. This is more important for the COMApartment object
(usually no objects are created in the COMThread - instead they
are only referred/called from it). So these objects created in the apartment can
function correctly only while the corresponding COMApartment is
alive.
Therefore if the COMApartment is destroyed (just released)
before all the other objects in the apartment are released they
will not be able to to exist nor uninitialize correctly. So the
best way to deal with COMApartment is to keep it and all the
objects created in it together. For example in Application
variables.
Similar is the case with the COMThread and COMScriptThread
objects. They
must be in Active state as long as the currently executed call
is in progress (do not call terminate unless there is some kind
of fatal problem).