Close all MDI windows explicitly when exiting.

Do it at the point when MantidPlot is still alive to avoid segfaults.

Refs #6691
Merge branch 'feature/6691_muon_save_deadtime_file' into develop