I have a couple of suggestions for you. Try them one-at-a-time (not at the same time) and let me know if either of them help, related to the issue-at-hand, or not.
1. Enable the RealPort exclusive option.
This has to be set from the command line. Telnet into the CPD, and issue the following 2 commands:
Set realport exclusive=on
The CPD will reboot after you issue the second command.
2. Log into the CPD using a browser. Then under Configuration, Serial Ports, select the CPD port which is connected to the touch screen, Advanced Serial Settings, and under TCP settings, check the box for the option Close connection after the following number of idle seconds, choose an appropriate value of maybe 10 seconds.
However, your application may or may not be able to tolerate the closing of the connection.