Fix browser closed before getting code