Here is the way how to close or quit from Telnet Terminal in Linux or Unix
First type escape character e.g. '^]' which is 'Ctrl + ]' and then type quit to close the telnet terminal in Linux or any UNIX system.
# telnet mail.grocery.se 25
Trying xx.xxx.xx.xx...
Connected to mail.grocery.se.
Escape character is '^]'.
220 mail.grocery.se Microsoft ESMTP MAIL Service ready at Wed, 25 Nov 2020 11:48:26 +0100
^]
telnet> quit