Command prompt hangs until keypress?

I have experienced the same issue. Answers here and here indicate this is likely an issue with Quick Edit mode in the console. If it intercepts stray mouse clicks, or if clicks get passed erroneously through RDP, for instance, it can unintentionally pause the script. You can right-click the menubar and edit properties to turn off Quick Edit mode. That, of course, makes it more difficult to copy and paste out of the CMD window.