There's no exit/disconnect command from the telnet interface (TiVo UI Control via Telnet - No Hacking Required!) unfortunately. In my Alexa skill, I just close the connection, which is what you're doing with taskkill. I'm assuming you're doing this on Windows since you mentioned a batch file. Maybe using a scripting language like VB would allow you to make it simpler and easier to do logic, looping, etc.