Can't close the system preferences
Some kind of message related to my Apple ID showed up on my screen (I forgot what actually said), so I clicked in. Then it goes to the System Preferences asking me to enter my Apple ID and password. I typed a wrong password, after it didn't accept it, I clicked "forgot the password". The dialogue box popped up asking to type a code that had been sent to my phone. I received the code and typed exactly what it said in the boxes, but the error message showed up saying it's invalid. I tried several times, but each time it gave me the same result. Eventually, a new dialogue box popped up and it says "Your request could not be completed at this time". In the dialogue box, under the message there is an OK button, so I clicked it, but it didn't do nothing; it didn't close the dialogue box. Because the dialogue box is still open, I can't close the System Preferences window (it shows "Apple ID" on the top) which is on the background of the dialogue box.
How can I solve this problem? By the way, I've remembered my password for Apple ID and don't need to change it.
MacBook Air 13″, macOS 12.0