It sounds like it’s just a unique thing with custom transactions so idk about solving the root cause, but to solve the symptom you could set a header field with a status of closed or billed or whatever, and then have your script check that status and re-set everything to closed if the status indicates they should be closed.