Free stdin on exit

r? @aturon