Fixed potential hangs on JRuby when Ctrl-C is used to shutdown the server. Fixes issue #1035.