Praise be to Allah.
There is nothing wrong with taking this money. Many scholars have ruled it permissible to benefit from retirement programs offered by the state, and they regard what is given by the state as coming under the heading of what the state is obliged to do of taking care of the weak.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him) was asked: What is the ruling on receiving a pension?
It is permissible to take it; a fatwa concerning that was issued by the Council of Senior Scholars.
End quote from Liqaa’aat ma‘a ash-Shaykh Dr. ‘Abdullah at-Tayyaar, part 1, p. 66.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: I am approaching retirement; what advice can you offer me? Should I resign and take what I am entitled to instead of retiring, because I heard that there are some reservations about it, even though it is more beneficial for me than what I would get when I retire, or is there is no problem with it, so I can take it?
He replied: I say: there are no reservations concerning it, in sha Allah. There are no reservations concerning the pension, because it comes from the bayt al-maal (state treasury). It is not a transaction between one person and another, such that we might say that there are some reservations concerning it due to the possibility of it involving riba. Rather it is something to which this retired person is entitled from the bayt al-maal, and there are no reservations concerning it. So stay in your job and take the pension, and I hope that Allah will put barakah (blessing) in it for you.
End quote from al-Liqa’ ash-Shahri (58/22).
Whether the state will pay the pension at regular intervals, or will pay a one-off lump sum, or give a lump sum at the end of one’s employment, in addition to the monthly pension, there is nothing wrong with you taking any of that, even if it is more than what was deducted from the employee during his years of work, or less than that.
And Allah knows best.