Allow java classes to close stdout/stderr

When the client calls a class, where either stdout or stderr is closed
the socket connection to the client is closed and no further data is
sent. This includes data transmitted over the other stream and exit
codes.
Merge pull request #25 from vhristov/for-issue23

Allow java classes to close stdout/stderr