I'm making a program that does various things in a complicated way and there's a a bug

I'm using a lot of modules which get used, then left alone for a long time, some of these modules use class modules, but a lot of the time instances of these classes are left open after the module is finished with.

I don't want to change the whole structure of my program to close them but I do want them closed.

Can I get a collection or something of all instances of a certain class so I can just loop through and close them.