--- ftp.pl~	Fri Jun  5 11:10:27 1998
+++ ftp.pl	Sat Feb  3 13:59:12 2001
@@ -270,6 +270,13 @@
 	$SIG{ 'PIPE' } = "ftp'ftp__sighandler";
 }
 
+# Setup a signal handler for user interrupts.
+sub ftp'set_user_signals
+{
+	$ftp_logger = @_;
+	$SIG{ 'INT' } = "ftp'ftp__sighandler";
+}
+
 # &ftp'set_namemap( function to map outgoing name,  function to map incoming )
 sub ftp'set_namemap
 {
@@ -581,6 +588,9 @@
 		return 0;
 	}
 
+	# shut down our end of the socket
+	&close_data_socket;
+
 	# read the close
 	#
 	$ret = &expect($timeout,
@@ -589,9 +599,6 @@
 		&service_closed();
 		$ret = 0;
 	}
-
-	# shut down our end of the socket
-	&close_data_socket;
 
 	if( ! $ret ){
 		return 0;
