DocumentSourceCloseCursor is part of the internal $changeStream machinery. It is used to close change stream cursors that have been invalidated, due to an event such as a collection drop or database drop.
DocumentSourceCloseCursor should always run on the mongos in the case that the $changeStream is run in a sharded configuration. This is because the mongos cursor manager is not prepared to correctly handle its child cursor being closed out from under it. Instead, the cursor should be closed via the DocumentSourceCloseCursor running on mongos. Cleanup of the mongos cursor should cause the underlying cursors on the shards to be cleaned up as well.
As of commit d4a526fdcf under
SERVER-30834, $changeStream will never pass through completely to the shards. Therefore, the DocumentSourceCloseCursor should always end up on mongos. Since it is not obviously wrong to pass through the change stream, we should add an invariant to make sure that this doesn't regress.