title: Command to disconnect SSH connection from Script
body: <p>I have this script:</p>
  
  <pre><code>#!/bin/bash
  #!/usr/bin/expect
  dialog --menu "Please choose the server to connect to:" 10 30 15 1 RAS01 2&gt;temp
  
  #OK is pressed
  if [ "$?" = "0" ]
  then
          _return=$(cat temp)
  
          # /home is selected
          if [ "$_return" = "1" ]
          then
                  dialog --infobox "Connecting to server ..." 5 30  ; sleep 2
                  telnet XXX
          fi
  
  # Cancel is pressed
  else
          exit
  fi
  
  # remove the temp file
  rm -f temp
  </code></pre>
  
  <p>In the part of the code that says: <code># Cancel is pressed</code> I want to insert some type of command that will disconnect the session and close the terminal automatically. Ive tried different variations of <code>exit</code>, <code>exit 1</code>, <code>exit 5</code>, <code>close</code>, etc. but none seem to do the trick</p>