Close input/output fds on program exit.
Abort if anything bad happens to the files.