The maggots do the hard work cleaning the wound. Cleaning up the maggots and poo is easy by comparison. But yeah you don't want to leave them there forever, just enough to remove the dead stuff.
Not as much as necrotic tissue still attached to the patient, I suppose.
(The idea is that these maggots are extremely good at debridement, that is, at eating only the dead tissue and leaving the still healthy ones alone; other methods, like scalpels, can't be so discriminating, and force the doctors to remove healthy tissue to make sure there's no necrosis left).