Close sql statements properly.