Whoever at the end leaves the body, thinking of any being, to that being only does he go, O son of Kunti (Arjuna), due to his constant thought of that being.
What it means
Whatever fills your mind when you die decides your next state of being. What we think about most in life naturally rises up at the end.
Word by word
yam yam—whatever; vā—or; api—even; smaran—remembering; bhāvam—remembrance; tyajati—gives up; ante—in the end; kalevaram—the body; tam—to that; tam—to that; eva—certainly; eti—gets; kaunteya—Arjun, the son of Kunti; sadā—always; tat—that; bhāva-bhāvitaḥ—absorbed in contemplation