I have the following script that opens a remote connection on the terminal:
xterm -e ssh -t user@IP -p porta "cd pasta && bash script.sh && exit ; bash"
How can I make the connection to be terminated and close the terminal after the script is finished?