Hi
just add another trigger to your trigger file to delete markets with matched bets, for example if you are backing:
action: delete market
conditions:
markets number of matched back bets is greater than 0
and markets number of unmatched back bets is equal to 0