Fixed closing of settings dialog.

Button event handling is getting pretty messy, as expected.