Hi
Actually, the inactive TS ports should be deleted during the restart of the Terminal Server. And it's not available to prevent Remote Desktop Service Device Redirector Service from creating a new port each session. However, the following suggestions show which possibilities are available ways with the question on your concerned.
Firstly, by default, it can only be deleted manually. Of course, the user can delete the inactive port registry periodically by running the following PowerShell script when logging off the user session.
Use PowerShell to delete the inactive port registry, please refer to this link. https://www.bvanleeuwen.nl/faq/?p=1423
Using GPO to Running PowerShell Startup (Logon) Scripts, please refer to this link. http://woshub.com/running-powershell-startup-scripts-using-gpo/
Secondly, you can enter get-hotfix in the PowerShell of Windows 10 and the Windows Server 2019 to see which patches are currently installed. Check and install the latest patch in Windows 10 and Windows Server 2019 to see if the issue fixed.
Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.
If the answer is helpful, please click "Accept Answer" and upvote it.
Best regards