close fd before callback