Properly stop the Qt app before stopping the reactor