Fix more crashes when the window is closed before the settings dialog.

These were introduced by the new refactoring of the preferences dialog.
Now that Host's are deleted and the pointer in the dialog code can be
null, ensure that it is tested before being used.
Merge pull request #128 from ahmedcharles/settings

Fix more crashes when the window is closed before the settings dialog.