Whenever you create a new session in your code, make sure you close it. Just call session.close()
When I got this error I thought I was closing all of my sessions, but I looked carefully and there was one new method where I wasn’t. Closing the session in that method fixed this error for me.