Closes an active connection. If a transaction is pending the connection is held open.