correctly set the cursor to closed if there's an exception
automatically close the cursor handle after the last row is fetched

(this is an alternative to 9ae761acc63bb61371fd8ff0ad8ad012818ddb49)
bump version