cleanup socket closing modifications made in 66dfab07

this constrains the modifications to ib/lib, rather than modifying the
automatically generated code in ib/ext