Added virtual machine shutdown hook to save preferences.

When ImageJ is run from a terminal and closed with CTRL-C, preferences are not saved.  I've added a shutdown hook for the JVM to automatically save preferences when ImageJ is closed in this way.