Added a begin around closing of IOs

On Jruby there seems to be a race condition that causes
$! to be set but no exception thrown. Putting this inside a begin
seems to fix this.

This becomes an issue because simplecov uses $! to detect if there was an exception thrown during a test run and it returns an exit code of 1 which fails the build. This only happens on Jruby (I can't reproduce this on MRI and didn't try any other versions).

I'm not really sure why $! is set but no exception is thrown, but it was always happening on the @read_io.close and contained a stream closed exception.

Let me know if you need more information or want me to change anything.