Fix database connection pool closing issue