The DBCommandCursor method _hasNextUsingCommands() should zero the "cursorId" property if the cursor has been exhausted.
A new derived class of mozjs::BaseInfo called CursorHandleInfo should be added, which should use the JSCLASS_HAS_PRIVATE class flags to store a shared pointer to a DBClientBase. CursorHandleInfo's finalize method should read the property "cursorId" from the given object (see mozjs/oid.cpp for an example), and issue an OP_KILL_CURSORS message (with DBClientBase::killCursor()) against the server if the cursorId is non-zero.
A new function "cursorHandleFromId" should be installed in mozjs::MongoBase, which should return a CursorHandleInfo object created with the MongoBase's connection and the given cursorId.
The DBCommandCursor constructor should add a new property to the object called _cursorHandle in read commands mode, which should be initialized from cursorHandleFromId().