Restore main window before close if it's iconized

Closing the main window when it's iconized, leads to a meaningless size
and position being saved to the settings file. The easiest way round
this is to just restore the window before closing it.