Add a shutdown hook for the command-line JRuby, to tear down.

We did not run teardown if the JVM was forcibly stopped using
ctrl-C, which in some cases could cause streams to remain
unflushed and other resources to be left dangling. However, we
don't want to set a shutdown hook if we're one of many JRuby
instances in a given JVM. This commit adds a shutdown hook only
if we're the top-level command-line JRuby (indicated by the
"hard exit" config flag) to run teardown at forced exit.