close unneeded file descriptors

Leaving them open may result in hitting ulimits
on some machines.