All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Whoever his last words were ‘Allaahu Akbar’, and he dies directly after that, then good is hoped for him as he died while doing a good deed as the Prophet said: “…The person of Paradise dies while performing a deed of the people of Paradise.” [Ahmad and At-Tirmithi] The scholars said: “…a deed of the people of Paradise means a deed that means that he is a believer who has certainty [with regard to his faith].” This includes any good deed and is not restricted to uttering the Shahaadah (the testimony of faith).
This general meaning is also supported by the saying of the Prophet “…And whoever fasts a day for the sake of Allaah and dies in this state [i.e. this is his last deed], he will enter Paradise, and whoever gives a charity for the sake of Allaah and dies in this state, he will enter Paradise.” [Ahmad] Thus, the Prophet mentioned that whoever dies and his last deed was fasting or giving charity, he will enter Paradise, so entering Paradise is not only specific to someone who uttered the word of Tawheed [The Shahaadah]; rather, he may enter Paradise through any good deed done at the end of his life.
There is no doubt that the word of Tawheed [The Shahaadah] is the best word a person may say as in the Hadeeth which reads: “…The best thing that I and the Prophets before me said is: “Laa ilaaha illa Allaah wahdahu laa shareeka lah, lahu Al-mulku walahu Al-hamdu, wa huwa ‘ala kulli shay-in qadeer" [‘None has the right to be worshipped except Allaah, alone without associate, to Him belongs sovereignty and praise and He is over all things wholly capable.]” [At-Tirmithi]
Allaah Knows best.