diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 3f160d382e7ab13e10c3f927d19da969a47ed417..d563070ae68e2098bdfbb4eb3fc5f4fd3e7c61a9 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.35 2000/07/17 18:24:32 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.36 2000/09/17 20:33:45 petere Exp $
  */
 #include "postgres.h"
 #include "command.h"
@@ -1237,6 +1237,7 @@ do_connect(const char *new_dbname, const char *new_user)
 		if (PQstatus(pset.db) == CONNECTION_BAD &&
 			strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0)
 		{
+			PQfinish(pset.db);
 			need_pass = true;
 			free(prompted_password);
 			prompted_password = NULL;
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 288c60d31089450f42ddc9ef1b009164b7b14c3c..f96cc7980ba7aa92b3947133692e8e345b16206b 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.36 2000/09/06 19:54:48 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.37 2000/09/17 20:33:45 petere Exp $
  */
 #include "postgres.h"
 
@@ -168,6 +168,7 @@ main(int argc, char *argv[])
 		if (PQstatus(pset.db) == CONNECTION_BAD &&
 			strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0)
 		{
+			PQfinish(pset.db);
 			need_pass = true;
 			free(password);
 			password = NULL;