Close inherited FDs.

Fixes #6257