def __del__(self):
self._all_modules_lock.acquire()<EOL>try:<EOL><INDENT>del self.ALL_MODULES[self.name]<EOL><DEDENT>finally:<EOL><INDENT>self._all_modules_lock.release()<EOL><DEDENT>
If modules are being used properly this will only happen on exit.