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[score_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[score_deaths=1] deaths 0
This kills all entities except for players in a radius of 10 around the dead player.
If this doesn't work, just tell me, then I have a different solution, but that one produces a bit more lag.