Hamas had to protect some hostages, otherwise they would have no leverage, and Israel would have had to finish this war once and for all.
A war is not over until the last combatant is either dead or lays down his arms, followed by terms of surrender.