Fix the potential uncloseable dialogs if starting a thread failed