To disconnect from the server when you no longer need to use it:
int rc; rc = qdb_disconnect(dbhandle); if (rc == -1) { fprintf(stderr, "Disconnect failed: %s\n", strerror(errno)); }