How to disable PlayerController when controlled Player destroyed

I write all the control(movement,fire) in PlayerController.
The question is when the player die while I’m not stopping control. After exit Gameplay It will generate a lot of warning/error remind me of the reference of controlled player doesn’t exist.
I try to make a Player State to indicate is player alive,and if not cut all the input event.
It works,but not perfectly cause it still will generate one warning/error sometime when I make some input at the time the player die.
How to radically solve the issue?
My thanks.

Just add a branch and check if the reference to the player still exists before using it. That would be the quickest way. Something like this:

You could even turn it into a macro if you want, or a pure function if you want to handle that boolean yourself every time