Chickens usually don't simply "stop" laying eggs when they get to a certain age, but they will lay fewer as they get older. That said, most laying breeds will lay more or less productively in backyard terms for five or seven years. We know of one ancient buff orpington cross who still lays an egg occasionally at 17 years old!! Factory farms slaughter their poor layers at a year old or so because those girls might lay a couple fewer eggs a week. Laying one or two fewer eggs just isn't usually important in backyard terms, even if you don't regard your hens as pets, but a commercial entity, a factory farm, sees "financial sense" in killing their all their one or two year olds and bringing in fresh chattel. Those poor birds, even "free range" commercial hens, may never have seen a blade of grass in their short lives!