Added try/catch to wrap close calls in handling sql exception.