Fix NoMethodError in io.close on server EOF

Affects capture* methods and probably some specific use cases of popen*