Civilians have a right to flee hostilities, but Hamas won't let them
Senior administration officials say Egypt was insisting no one could come out of Gaza until all the aid got in, but that those Egyptian officials have now relented, but now Hamas is holding up the exit of the Americans.
NBC News, Frustration Grows Among U.S. Citizens Stuck in Gaza
“The Parties to the conflict shall, to the maximum extent feasible: (a) … endeavour to remove the civilian population, individual civilians and civilian objects under their control from the vicinity of military objectives”
Additional Protocol I, Art. 58
In simple terms, there are many civilians who want to get out of Gaza. I would bet dimes to dollars more than just US citizens want out. Hamas, as a party to the conflict, is bound by international law to let civilians leave. If they will not permit US citizens to flee, one has to infer they are also refusing to let their own people leave.