How to prevent multiple window with url https://twitter.com/i/oauth2/authorize

I’m opening a new window with url https://twitter.com/i/oauth2/authorize?scope=tweet.read%20users.read%20follows.read%20follows.write&state=state&client_id=clientID&response_type=code&code_challenge=789089&code_challenge_method=plain&redirect_uri=http://localhost:4200/app/callback

But, when the url is loaded in new window, the popupWindow.closed property is getting set to true. Hence, leading to multiple windows getting open on button click. This doesn’t happen with linkedin’s oauth url

if (this.popupWindow == null || this.popupWindow.closed) {
      this.popupWindow = window.open(
        `${authUrl}?${params}`,
        'twitter',
        `menubar=no,location=no,resizable=no,scrollbars=no,status=no,toolbar=no, width=${width},height=${height},top=${top},left=${left}`
      );
    } else {
      this.popupWindow.focus();
    }

How do i prevent multiple window from opening?