There is currently no way to stop PVP logging in realm, since they don't support plugins or mods, nor is there a built-in option for anti-PVP logging. It's not possible to make an anti-PVP log mechanic with commands, either. This results in players being able to leave my realm to prevent themselves from dying to other players, or mobs. And the only thing I can do about it is /kill them for it when they rejoin, but if I'm not in the realm to see it happen, I cannot do anything about it, as I cannot prove they did it.
We need a built-in option to stop leaving the game to prevent death. If a player leaves while being attacked by mobs, a player, in lava, or being crushed by falling blocks, it will immediately kill them, so when they join back, they are dead. This would be very helpful for minigame realms and/or hardcore survival realms to prevent abusing leaving the game.