You don't. Maggots only eat dead flesh. Once its gone the drop off and look for more dead flesh
Just to be really argumentative, there are two slight problems here.
Firstly, if you have to place a covering over the wound to hold them all in their to start with, so they can't simply drop out. So once they have
done their work if you have a large wound they will wonder around the area looking for more, if this is unsuccessful most maggots will either die or
try to pupate.
Secondly, not all maggots eat only dead flesh, if you have the wrong kind, then the last thing they will do is leave quietly.