Close stdin/out/err before forking.

This ensures that if the parent shell exits, the tty can be closed (e.g.
when running in screen the window will close automatically instead of
waiting for all forked rmate processes to exit).