How to avoid engine destroy the character when player leave or get disconnect

, is there any way to replace player controller with AIController(in c++ or in blueprints)? I mean if human leaves or disconnects then we just put AI instead and AI controls pawn in future.