Even when only the number of active instances is different (for example: getActivityInstanceAttribute("numberOfActiveInstances") == 1) and there is one active task inside the subprocess, the ad-hoc subprocess does not end. The completion condition works only when it is exactly as stated above in summary (so when there is no active task inside the subprocess, then the subprocess ends). See the pull request: https://github.com/droolsjbpm/jbpm/pull/56, commit: https://github.com/rsynek/jbpm/commit/7e1fe98179268865f70ef7c37aa299a7ca02d81c for more information.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: When using Ad-hoc subprocesses the completion condition is limited only to: getActivityInstanceAttribute("numberOfActiveInstances") == 0, when the number of active instances differs, the ad-hoc subprocess does not end.