helper: close file descriptor