Do NOT hold foreign objects at module level

The ordering of Python module cleanup does not guarantee that the module
that holds foreign library is cleaned up _after_ all modules that hold
foreign objects.