Clean up cursors in try/finally

Make sure we release cursor resources.

Change-Id: Ia122100b1350ae5db4804f8f0e95c49785ab645b