Fix leak of database connection