Close the collocation database when indexing is done

The collocation database runs without a write ahead log and nothing closed it,
so everything that was still in a write buffer was lost when dereko2vec ended.
Measured with collocatordb: of 2 million increments in a process that just
exited, none were readable afterwards.

Needs collocatordb 1.6.0, which added close_collocatordb() for this.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: Id6a7d70050e149aa81d4216b9bdc293c618a3b79
diff --git a/src/dereko2vec.c b/src/dereko2vec.c
index 9b10c22..d7a783a 100644
--- a/src/dereko2vec.c
+++ b/src/dereko2vec.c
@@ -2100,6 +2100,17 @@
 	}
 	SaveArgs(argc, argv);
 	TrainModel();
+	if (cdb != NULL) {
+		/* Writes what is still in memory. The collocation database runs
+		   without a write ahead log, so the counts of the write buffers that
+		   were not flushed yet are lost without this. */
+		if (debug_mode > 0) {
+			printf("Closing the collocation database ...\n");
+			fflush(stdout);
+		}
+		close_collocatordb(cdb);
+		cdb = NULL;
+	}
 	return 0;
 }