Close SQLite cursors when creating functions.

If the cursors are not closed, then when
create_function is called, if they are not
GC'd then create_function will fail. On Pythons
without reference counting (e.g. PyPy) they
will not be GC'd immediately.

Change-Id: I39210616d323691ccb745149f24430a7a61382ec