Close cursors after they're not needed any longer.

Fixes #152