Bridges > COM Import Bridge and ActiveX > ActiveX Controls > Destroying ActiveX Controls

# Destroying ActiveX Controls

An ActiveX control incorporated in an IDL widget hierarchy is destroyed when any of the following occurs:

- When the widget hierarchy to which the ActiveX widget belongs is destroyed.
- When a call to WIDGET_CONTROL, wAx, /DESTROY is made, where wAx is the widget ID of the ActiveX widget.
- When the underlying IDLcomActiveX object is destroyed by a call to OBJ_DESTROY.

In most cases, cleanup of an application that includes an ActiveX control is not different from an application using only IDL native widgets. However, because it is possible for an ActiveX control to return references to other COM objects to IDL, you must be sure to keep track of all objects created by your application and destroy them as necessary. See References to Other COM Objects for details.

In addition, it is possible for the widget event structure generated by an ActiveX control to include IDL pointers or object references. Pointers and object references included in the event structure are not automatically destroyed. See Dynamic Elements in the ActiveX Event Structure for more information.