A student in my experimental psychology class last semester did his project on increased religiosity towards the end of the lifespan. I understood his thought process to be something along the lines of "people get more religious as they get older, perhaps because the closer one is to death, the more salient death becomes, and this triggers the defense/coping mechanism of fervent belief in a belief system that offers life after death." I had also suggested that the erosion of social ties the elderly experience because of our cultural isolation of the elderly and because their social networks literally die off, might provide an impetus for increased religiosity because involvement in churches provides for increased social capital.
Now that I've been reading Bowling Alone by Robert Putnam, I realize I missed something huge--the current elderly population is the generation that throughout their lifespan has been consistently the most civically engaged generation since measurement of such started. So looking right now at the elderly population and seeing their greater social capital--definitely including church attendance and church-based activities--fails to consider the generational attributes, and its is probably mistaken to, from just a current snapshot of data, to conclude increased religiosity over the lifespan.