Hello, @GRS,
Welcome to the Microsoft Q&A platform!
Based on your description, I understand that you want to run some commands in PowerShell, but you can't know if the connection is successful and why the window closes automatically. However, I want to share the following with you. The screenshot you offered above shows that you have successfully connected. Also, the Get-AcceptedDomain works successfully in my test as below.
Therefore, please kindly refer to steps of Connect to Exchange servers using remote PowerShell | Microsoft Learn to see if there are anything missed.
Also, I suggest you could change another command to test such as Get-Mailbox to see if the window disappears as well.
Looking forward to your update and please feel free to contact me if you have any queries.
If my reply is helpful to you, please mark it as the answer so that other users can refer to it. Thank you for your support and understanding.
Best,
Alex Zhang