221 Service closing control connection.
Logged out if appropriate.
ftp returns series codes - numbers like 500 or 221. These codes tell you what happened to a particular request. 221 can mean things like 'the connection was lost' for example.
You have to ask yourself - why would the remote server close the connection?
Or why would it look like that from my end? If you need an absolutely detailed account, you would have to be able to monitor what was going on at the remote host just when it returned 221.
The simple answer is to retry the operation. If it fails three times, send an email to the sysadmin or whoever is appropriate. This means you have to check codes in the script. For a complete list of these codes go to RFC 959 http://www.faqs.org/rfcs/rfc959.html