close fd when error