Thanks for the responses, they are very helpful. What I want is for the sftp to disconnect when the Stop button is pushed. that way the script allows the user to change the variables and run the transfer again.
Right now I am trying to understand how zentara's code works since it incorporates syntax I have never seen (and it seems to make it easier).
One problem is that the program connects right away not allowing the user to change the variables before it is connected to the server. I moved the SFTP connection to work only when $go = 1, that way it only connects of you push connect. But you cant change the variables like username from jlahowet to something else. It wont pass the new value to the thread for some reason, any help?