Chapter 8 Brahma Yoga Verse 6
Shloka
Yam yam vaapi smaran bhaavam tyajatyante kalevaram;
Tam tamevaiti kaunteya sadaa tadbhaavabhaavitah
Translation
Whosoever at the end leaves the body, thinking of any being,
to that being only does he go, Arjuna, because of his constant thought of that being!
Interpretation
After talking about the person attaining His being, when he thinks about Him at the time of death, Lord Krishna in this sloka talks about what happens to those who dont think about Him at the time of death. The blessed Lord says that a person who at the time of death thinks about whichever being,  he will go to that being only. That means a person goes to the same thing that he/she thinks of. It is because of the universal rule that says you will always be drawn towards the being that you are thinking of.
Extending Interpretation to Mankind’s Life!
There is a quote from Rhonda Byrne’s book “the Secret”, we get from the universe the thing we think about and by that thinking, we attract that thing and the universe bestows the same thing to us. This is not only applicable in life but also at the time of person’s death. What a person is thinking at the time of death, goes as a major trigger into his subconscious mind or the soul as we call it and the person’s soul takes that thought only while leaving his body. So, the person’s soul will only think about that and will play a major role in shaping up the thought process in his next birth.
The most prominent thought that is there in one’s life occupies the mind at the time of death. It determines the nature of the body to be attained in the next birth. The thought at the death cant be controlled by any human being. He will never think about what he wants to think, but he will think what his nature forces him to think. So, when a person is thinking about money and earning more money and not satisfied with his earnings, he will be a miser in his next life and will only live for earning money. That is how a person will be drawn in his next birth, what he was thinking at the time of his death.