make sure that fd actually exists before we close it.