Closing database cursor