Close filedescriptors after using

Change-Id: I5bbc1fa51ebc6e2aae8fc217ab6fba9aeb1f6439