diff --git a/ftpsync/ftp_target.py b/ftpsync/ftp_target.py
index <HASH>..<HASH> 100644
--- a/ftpsync/ftp_target.py
+++ b/ftpsync/ftp_target.py
@@ -72,6 +72,8 @@ class FtpTarget(_Target):
         self.is_unix = None

         self.time_zone_ofs = None

         self.clock_ofs = None

+        self.ftp_socket_connected = False

+        self.connected = False

 #        if connect:

 #            self.open()

 

@@ -90,6 +92,8 @@ class FtpTarget(_Target):
 

         self.ftp.connect(self.host, self.port, self.timeout)

 

+        self.ftp_socket_connected = True

+

         if self.username is None or self.password is None:

             creds = get_credentials_for_url(self.host, allow_prompt=not no_prompt)

             if creds:

@@ -142,7 +146,10 @@ class FtpTarget(_Target):
     def close(self):

         if self.connected:

             self._unlock(closing=True)

+

+        if self.ftp_socket_connected:

             self.ftp.quit()

+

         self.connected = False

 

     def _lock(self, break_existing=False):
Fix #<I>. FTP socket connection not closed after calling close() method