diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index 67e2877..e1a3a53 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -193,3 +193,31 @@ class DatabaseWrapper(BaseDatabaseWrapper):
                 return self.connection.commit()
             except Database.IntegrityError, e:
                 raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
+
+    def close(self):
+        if self.connection is None:
+            return
+
+        try:
+            self.connection.close()
+            self.connection = None
+
+        # in some cases psycopg2 can throw an exception on closing, some of
+        # these exceptions indicate that the connection has been closed, try to
+        # recognize those and mark the connection as closed.
+        # Taken from http://www.sqlalchemy.org/trac/browser/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+        except psycopg2.OperationalError, e:
+            if 'closed the connection' in str(e) or 'connection not open' in str(e) or 'could not receive data from server' in str(e):
+                self.connection = None
+            else:
+                raise
+        except psycopg2.InterfaceError, e:
+            if 'connection already closed' in str(e) or 'cursor already closed' in str(e):
+                self.connection = None
+            else:
+                raise
+        except psycopg2.ProgrammingError, e:
+            if "losed the connection unexpectedly" in str(e):
+                self.connection = None
+            else:
+                raise
