How do you kill all mobs after you die?

You first have to create a scoreboard like this:

/scoreboard objectives add deaths deathCount

Then you put a repeating, always active command block somewhere out of sight (but still in the loaded area), containing this command:

/execute at @a[scores={deaths=1..}] run kill @e[type=!player,distance=..10]

And in the direction the repeating command block is facing put an always active chain command block (can be conditional if you make it face the same way) containing this command:

/scoreboard players set @e[scores={deaths=1..}] deaths 0

This kills all entities except for players in a radius of 10 around the dead player.