Issue #4471: Properly shutdown socket in IMAP.shutdown().  Patch by
Lorenzo M. Catucci.
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 1b37546..e020747 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -260,6 +260,7 @@
     def shutdown(self):
         """Close I/O established in "open"."""
         self.file.close()
+        self.sock.shutdown(socket.SHUT_RDWR)
         self.sock.close()
 
 
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 8d86ce6..351659d 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -217,6 +217,7 @@
 
     def test_logout(self):
         rs = self.server.logout()
+        self.server = None
         self.assertEqual(rs[0], 'BYE')
 
 
diff --git a/Misc/ACKS b/Misc/ACKS
index 361cdf9..3cb3a29 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -130,6 +130,7 @@
 Brett Cannon
 Mike Carlton
 Terry Carroll
+Lorenzo M. Catucci
 Donn Cave
 Charles Cazabon
 Per Cederqvist
diff --git a/Misc/NEWS b/Misc/NEWS
index 19e653c..5cd6647 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,9 @@
 Library
 -------
 
+- Issue #4471: Properly shutdown socket in IMAP.shutdown().  Patch by
+  Lorenzo M. Catucci.
+
 - Fix IMAP.login() to work properly.
 
 - Issue #9244: multiprocessing pool worker processes could terminate