Fixed many SQL connections not being closed.