The error you get can have a lot of causes. It could be a problem in your own code or in the ActiveX control. For example, your process might terminate, yet one of the threads is still running, polling for information or whatever.
Chances are that you don't free the ActiveX control correctly, thus causing something that leaves some unfinished business behind. Running your application within the debugger could provide you the location of the error but chances are that it's a bit more complicated. Sometimes, sh*t just happens...
Did you create a small console application to test this OCX? Or did you import it as a component and did you add it to a form?
In the case of a console application, make sure you're not using a global variable to store the OCX object! Global interfaced objects aren't always released correctly.
If using a component on a form, add an OnClose event on this form and add code in this event that should clean up the OCX control. Don't free it, but see if it has a "Close", "Clear" or "Terminate" function or other cleanup method that needs to be called. And again, don't use global variables for interface-based types like OCX controls.