Dispose of old main window when calling setMainWindow

After check for equality