closing database connections after db queries