Close cursor after use

Close cursor after use in context manager seems to keep the socket use down.