close filedescriptors after failure