When was the last time a US general was killed in a combat zone? 2014. And it was a green on blue attack—not even in the field.
Generals should not be that close to the enemy. They are supposed to be more valuable behind the line—plus the risk of capture is more damaging than their deaths.
Losing Generals in modern warfare is pretty rare.
It depends on how the war is fought and what country is fighting it.
US generals sitting at some console in Florida are not going to get killed in Afghanistan.
Russian generals, actively engaging the enemy in Ukraine on the battlefield can and do get killed.