"Swami Vishwananda" has given a good answer and example of "Shishupal" by "Seeker" is also a good point to mention. I agree with both of them and would like to share and elaborate my view on this. Please correct me if I am wrong on any point.
One may wonder, if just remember the God at the time of death is enough for getting liberated. If so, what will happen if any person recites God at his end time but his soul is very impure. Will he still be liberated?
First of all, I believe that when we say "Uttering" Gods name does not imply just to making sound out of mouth. The name of God must be taken from deep inside the heart, not from the tongue. It does not matter if one ever pronounces Gods name or not, as long as he is remembering at his heart. Even the name is not necessary. If one recites just the figure of God or even just the sense of God, then that will count. So, just saying "Narayana" at the time of death is not enough. It must come from the heart with Devotion towards the God.
Devotion is something that God admires a lot but also an equally rare thing. It is not found with everyone. When we speak of Hindus, there will be very few who will never go to Temple or worship to God. But is that Devotion? I don't think so. It is just a kind of activity by us. Devotion is a rare Gem that is found only within the individuals with Pure Soul. For one to recall God from his heart at his last moment, he must be practicing this throughout his life. One suddenly can not think of God at the time of death when he has not been doing so regularly in his lifetime. So, I believe that one who do not have pure soul will not be able to think of God with devotion. Hence that will not get him liberated.
What will happen to an individual who has pure soul and who has been devoted to God throughout his life but my mistake or due to some circumstances he remembers other things and not God at his end time?
There are mentions of such cases and examples in Upanishads. There is one episode regarding that on famous serial "Upanishad Ganga". Veda and Upanishads mention the importance of reciting Gods name at the time of death and on failure of doing so it is stated that one will have to take rebirth once again. There are examples of Yogis and highly spiritual individuals who failed to do so and then were reborn. So, the crude reply seems to be No, he will not be liberated. But there is more to this.
First, I would like to restate the fact that any individual who has been devoted to God his whole life, how can he not remember God during his last moment. It will not only be a tough job but an impossible task for someone who has not been near to God during his lifetime but not for someone who is a real worshiper of God. It will be like a daily routine to him. He will never forget him. On every activity he does and at every moment he is thinking about God. So, it is highly unrealistic that he will think about anything else during his last moment. It does not matter whether the death is sudden or an accident. If one thinks of God every moment then it dose not matter if the check is done on the first moment of life or last or any other moment in between.
One may argue that thinking about God every moment must be a very difficult if not next to impossible. But that is not true. I can say that with my experience. I cannot say that I always recite God and only God every moment of my time. But I can say that I do remember him most of the time. I associate him with everything and think about him when doing any activity. It is not like it has to be 100% of time or every second. It is more like in the sense of Generally. God looks at the "Sense" or "BhAva" and not Words. And I am not a Yogi or a very Divine person. I am just like anyone else. I may be slightly more devotional than average individual but I am still not that highly Spiritual. So, for highly spiritual it is not the matter of ease of difficult not it is any option for them. It is like breathing to them, and comes naturally.
Therefore, the true answer to this question is not just blunt NO. A true follower of God is never separated from God, at the time of death or any other time. So, he will be liberated. But we human are not perfect. Time and again we fall from our position. So, one cannot discard the fact that no matter how spiritual we are or how pure soul we have, we are liable to make mistake at our last moment. We are prone to foster of Desire within us. Desire is the key to the cycle of Life and Death. As long as we have any desire we can not break through this cycle. So, there is very likely possible that we think of any of our desire and not the God. What will happen then?
Since we are not free of our desires, we will have to take new birth according to what desire we have. So then all the devotion and spirituality of lifetime is wasted just because of the last moment? It is not like that. It is true that we missed our opportunity of getting enlightened at the very last moment, however, all that devotion and spirituality is does not go wasted. As we know, anyone who does good, will not come to a bad end himself. So, all that good deeds will help him in retaining good spirituality quickly and gives one more attempt to become One with God.
When we talk about God and Spirituality, the faith and sense or (BhAva) is more important than Words or Acts. One may be a priest of a temple throughout his life but may not take Gods name from heart even once. So, in Gods world acts and deeds are not important. Going to temple is not that important as going to temple with Faith and Pure Heart. We can not decide whether to remember God or not at the time of death. Only at that last moment, it will be revealed. We are not in control of that. What we are in control of is what we do now. Only if we think of God from our heart now then we might be blessed by God and make us remember to call him at the last moment. Or else, it is not a lottery that has some chance of winning and we may or may not remember God when we are about to end this life.
We may not succeed in our liberation even after the lifetime of worship and devotion to God and may need one or many other lives to get to that point. It is not certain but one thing is sure. If we do not get in God now, we will surely fall into some worldly desire at the time of test. So, it is Now that is more important than what we will do at our last moment.