ensure that the IOServer thread terminates

Previously the application only exited if system.exit was called, when the IO server had been initialized. This causes ktest to time out instead of failing if an uncaught exception is thrown by the pretty printer. This code fixes that by using java.nio in order to allow the thread to be interrupted while waiting on a socket, causing the application to shutdown in an orderly fashion.

Does anyone happen to know anything about threading who might be able to review this?