Close all MDI windows explicitly when exiting.

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

Refs #6691