There's this story I read a long time ago, about a few hindu preists. They all had this same question: what will happen to them if (due to amnesia or other reasons) they fail to fix their mind on the Lord at the time of death. So one of them went inside the temple hoping to get an answer directly from the Lord.
And God replied to him that He will take care of them (the ones who lived a pious life) even if such men suffer from forgetfulness at the time of death.
I think what matters to God is, what we believe in and how we live our lives. :=)
I do not think the mind has to be fixed on anything in particular at the time of death, because God knows our heart, regardless of what we are actually thinking at any point in time.
I believe that both faith in God and good deeds matter to God.
Baha’is do not believe that heaven is a geographical location, but a Baha’i once asked the Guardian of the Baha’i Faith (Shoghi Effendi) how to get to heaven, and here was his answer...
"To 'get to heaven' as you say is dependent on two things--faith in the Manifestation of God in His Day, in other words in this age in Bahá'u'lláh; and good deeds, in other words living to the best of our ability a noble life and doing unto others as we would be done by. But we must always remember that our existence and everything we have or ever will have is dependent upon the mercy of God and His bounty, and therefore He can accept into His heaven, which is really nearness to Him, even the lowliest if He pleases. We always have the hope of receiving His mercy if we reach out for it."
(From a letter written on behalf of Shoghi Effendi to an individual believer, January 12, 1957)
Lights of Guidance (second part): A Bahá'í Reference File