When are db connections closed?

If you are able to take a look at this thread: OperationalError: sorry, too many clients already do you believe there’s a chance this could be the cause of the issue described there?