Generally speaking, if the heap item is preceded with '$', it was created by the system, belongs to the system, and must be deleted by the system...generally implicitly by the counter operation to that which created it, in your case, the deletion of the device that used it.
The order of the system configuration pages is significant and there are dependencies. The CPU page can enable things that affect the I/O page. The I/O page contains things that need Module Configurations. Module configurations can create devices. Devices can create heap items.
Since devices can be created by the user or by module configs, some can be deleted by the user, but some must be deleted by changing or deleting the module config.
Since heap items can be created by devices or by the user, some can be deleted by the user, but some must be deleted by changes to devices, which might also be changes to module configurations.
It may not be intuitive, but it is specific and predictable once you understand the dependencies. Do-more isn't Click, but then again, I doubt you will be creating custom TCP protocols in Click.