When a Sim reaches the elder stage, its lifespan still follows the setting you've chosen. For example, if you set the lifespan to 90 days, a Sim might live to around 100 days. I'm not entirely sure whether they can also die sooner than that, but the lifespan setting is the main factor that governs it.