Attempt to avoid mainWindow dead object errors