Bring back on-demand commit closure preparation

Turns out this was needed, because the value of can_close() can flip
while another commit is being processed.  Just keeping the set of
things to iterate steady during each pass isn't enough.