O Kaunteya (Arjuna), whatever one thinks or fondly contemplates upon while shedding the body, that itself he attains, governed by the law of wholesome identity.
Krishna explains the proposition more lucidly. Whatever form or idea one thinks about in the end assiduously, while shedding his body, that very identity follows him irresistibly; meaning, he attains it.
There are three states for us, wakefulness, sleep and dream, on which our life and living subsist. Each is dependent on another and is mutual to it. Amongst these, wakeful experiences alone are subject to common rational study and analysis.
Bhāva, attitudinal association, determines the growth and transformation of the mind. The bhāva one fosters, especially at the time of death, is crucial in determining the state and outcome one begets thereafter.
In fact, we have awareness and its effects only till the body breathes its last. So, what happens to anyone after death is more a surmise than any experience or realization. And doubts are bound to prevail therein.