When someone dies, if they are destined for hell, do they stay there for all eternity?
The disbelievers will stay in hell forever, and they will be punished however much God wills.
or will they eventually be freed from hell?
But, those people who have the smallest amount, like an atom or a small mustard seed, of faith/belief, then they will be let out of the hell fire.
If they will eventually be freed, what happens then?
They are let into paradise. I hope the following Hadith clarifies that question...
Allah's Messenger (ﷺ) said, "When the people of Paradise have entered Paradise, and the people of the Fire have entered the Fire, Allah will say. 'Take out (of the Fire) whoever has got faith equal to a mustard seed in his heart.' They will come out, and by that time they would have burnt and became like coal, and then they will be thrown into the river of Al-Hayyat (life) and they will spring up just as a seed grows on the bank of a rainwater stream." The Prophet (ﷺ) said, "Don't you see that the germinating seed comes out yellow and twisted?" Source.
Do all people stay there for the same amount of time?
I am assuming that you are referring to those who stay in hell. As for how long, I can say as long as God wishes (Or, there is a deduced belief that they'll be burnt until they're re-payed for their bad deeds. But, the measurement of compensation is again in the hands of God, so God's wish).