close cursor and conn of sqlite once finished