Technically, you could play a fort indefinitely. Food, as in cultivated crops and raised livestock, is a renewable resource. Same goes for trees and wild edible plants.
Other resources, namely minerals, are not renewable, but you can expect to always have enough stone. Ores, not so much, unless you mod the game in a way that makes them more common (if you're interested, I can give you details on how to do this). You don't need those to last indefinitely in order to survive, but you do need them in order to make anything worthwhile. Watching your dwarves eat and drink for years is going to be boring unless they're also producing interesting things out of metal or stone.
As far as stone is concerned, that can be replaced by glass, at least for most uses. As long as you have sand and magma, the latter being an infinite heat-source for furnaces, kilns, smelters and forges, you are going to be able to produce glass furniture, walls, jewelry, etc. for years (real time, not game time).
Dwarves can die of old age, but live pretty long. They do reproduce, however, so them going extinct is not a concern, unless by catastrophic means.
As to depopulating potential attackers, I'm not sure. I think I've read that it was possible, but I haven't experienced it myself. Note that I'm talking about fortress mode here, as in adventure mode it is definitely possible, but unbelievably tedious.
Now, most importantly: the above is all academic. Believe me, you are not going to play a fortress indefinitely. You might get bored with your layout, or your site's features, and want to try something new. Hell, even if you never got bored, surely you would want to start a new game whenever a major update comes along, wouldn't you?