If a battle lasted several days, how did that... work? Obviously, you can't have the same guys fighting continuously the whole time. How did they get out to have a rest or go to sleep? Or did they just fight until they dropped? Did generals have to factor this in to their strategy? Did everyone just stop at night?
They did stop regularly. Battles were not non-stop fighting. There would be pulses, period of intense fighting and periods were not much happened. If no army yielded they would generally call it a day at nightfall and start again the next day, until one of the armies routed or surrendered.
Herodotus' account of the battle of thermopylae, made famous by the movie 300 (the movie is great entertainment but do not ever take it as a reliable historical source), makes countless references to troops from both sides taking their meals, resting etc... suggesting there were indeed a lot of downtime.
As explained they would certainly stopped and attacks would be more in waves trying to force the other give way, collapse or simple retreat. Most battles would end when one of the armies collapsed or panicked and fled while the "winners" would be in command of the battlefield and the troops would typically engage in looting; they'd retrieve whatever possible from the enemies corpses, from clothes to jewels, weaponry and any other valuable. In addition night would mark the end of hostilities until the next days. American Civil War is a not so distant example, darkness would make everything to stop and settle to eat, rest, care for the wounded and reload for the next day. (ie: Gettysburg). Moreover until the coming of modern firearms fight would be physically exhausting, a Roman legion or a Greek phalanx could go on for may be 1 hour at full throttle, sometimes less, they would not be thrusting from 0900 AM to 1900 PM, it is not possible physically.