beam2/unix: fix file descriptor leaks