Added virtual machine shutdown hook to save preferences.

When ImageJ is terminated using Ctrl-C or the JVM is otherwise shutdown, ImageJ does not save its preferences.  I've added a shutdown hook to handle such cases.