how to close telnet session in shell script