the very concept of "pensions" is so steeped in capitalist society that i can not perceive of an anarchist world where it has any relevance whatsoever.
also, as human points out, the phrase "when a person isn't allowed to work anymore" is so authoritarian sounding that it raises serious issues around the question in general.
if, as human also mentions, you are really just asking what happens to folks that are not capable of meeting their own needs, there are a number of questions/answers on this site that address that (try searching the site for terms like "disabled", "elderly", etc - also look at the tags page).
the bottom line for me: it's all about relationships. folks that care about each other, take care of each other (as necessary/desired). no state, laws, contracts or any other coercion necessary.