ESC key in Teams is to close new windows except the client itself. For more information, you could refer to this article.
According to your description, this question is more related to development. As we are mainly responsible for general issue of Microsoft Teams, I would add office-teams-app-dev tag and remove office-teams-windows-itpro tag. Hope you get better response.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.