Yes, "sins" are "forgiven"
There are many verses for "sins washed out" throughout Gita. Citing few of them below, to establish the authority of this concept:
Gyan Yoga (Sundar/Beautiful): Once a person conquers the Rajo-guna and identifies himself with absolute, all his past deeds are freed, be it good or bad. Would merge within the supreme without any Karma lingering.
Karma Yoga (Sahaj/Trivial): The true Sanyasi is the one who lets go the fruits of Karma, because a person cannot get rid of doing (good/bad/ugly) Karma due to material nature influence. But those who have renounced the fruits of action are unaffected and would get Moksha; others would get good, bad, mixed fruits.
Bhakti Yoga (Saral/Easy): Once a worshiper completely surrenders self to supreme or any manifestation of supreme by remembering in any way, he/she is intact from any sinful reactions & ultimately merges to God.
With above approaches, if one lives his/her life then quite likely that during death the same tendency will be retained. Similarly, if one lives life in ignorance or wish-fulfillment, then it's very less likely that God can be remembered at last moment. Because the moment of death is said to be quite testing and creating such tendency instantaneously may require saadhana of many births.
Now one may ask, if I misbehave with someone and then think about God, is my sin gone? Theoretically it's possible, but practically there is a catch:
- Did I "behave" or "misbehave" or "well-behave"? 1st one doesn't have
any result. So even if others say "misbehaved", there is no sin. But
if I am able to judge "mis"/"well" myself then it's a fruitful action!
So even if I remember God, this attachment will remain subtly just
waiting to kick-in someday!
The "sin" is a relative term. Two persons of different philosophies may think that other one is committing sins. However both themselves are just acting naturally.
Sometimes a person will assume certain action sinful due to ignorance or rationality or weighing on the profit/loss. But in actuality not performing that action would be sinful.
Why "sins" are "forgiven"
Indeed true that a person committing "heinous crimes" if remembers God during death, then reaches God irrespective of whatever Karma. Ramananda Sagar's TV series Krishna has got this sloka right. However, the "why" part was missed.
This verse is quite controversial and can be used by critics of Gita against it. To explain it, I have to present another few controversial thoughts which are implicit:
- We don't need to necessarily love God with compassion; we can even hate
the God continuously, we will reach him
- Surrendering to any(right/wrong) Guru helps reaching God.
Let's understand 2 important words from your original verse:
Often the universal appeal of this word is missed by translating it as:
Me = Kṛṣṇa © 3000 BC, India. All rights reserved.
We should remember that here Krishna is talking as a self realized supreme soul to Arjuna. Now certain things cannot be translated into words, so he uses the term "Me" as the closest. The "Me" is creator, supporter & destroyer of universe, its Maya and just everything.
At the level of soul, the "Me" part of you and the "Me" part of myself/others is no different than the "Me" part of Krishna. Our current "body" identities are just certain combinations of material nature. Material nature combos are "ever-existent temporaries".
"Remember (Fixed upon)"
This is the keyword which we often get it wrong. Love is not the only devotion humans have! What if a person's nature doesn't have "Lovingness", rather is always "Hateful". What if the person isn't even "Hateful", but he/she is always a "Critic". What if he/she is just a "Mocker" or "Fearful". What if mix of many emotions?
A person has right to act according to his Swadharma. God in form of enjoyer/Anandmaya Sharira enjoys all the Rasa/emotions.
A hateful person may take births or ages to become loving, why to have a long wait? Just hate God as your enemy, hate like how Shishupala did. Or being a cruel person, get frightened from the God like how Kamsa did. Because their minds were always fixed upon Krishna.
Emotions like "Hatred", "Fear", "Envy" are self defeating compared to "Love", "Compassion", "Friendliness", hence their reactions are sinful. But based on own nature, one can use those "tools" to remember God.
Remember (Devotion) = not being Indifferent
A real non-believer is not the one who consciously say, "I don't believe in God", but the one for whom existence of God doesn't matter. He/she is ok even if God exist, or ok if doesn't. Plain indifference.
If one's nature is crooked then all the so called scriptures will not help become divine. One's Swa-Dharma is defined by inner material nature and should act according to it. Such people don't have any sinful reaction because they are just doing their duty. It's better not to copy even those, who are considered 'good' according to the society.
Even the "enlightened" people act according to their typical nature, it's not to be repressed. Because, it's easier to give away the fruit of your Karma, when it's done according to Swa-Dharma (Swabhavik Dharma). e.g. if your nature is not to cheat then you won't attach to the Karma of buying milk in exchange of money from store. But if my nature is of a thief and if I buy milk ethically then it's quite likely to get excited about that "good deed" and get attached to it. For me it's better to avoid that "interruption".
Now pure Bhakti Yogis don't have even that much discrimination/discretion/Viveka. So they surrender themselves to someone to whom they think has such discretion. That might be any person or deity or God or even an idol. Now "surrender" means, even the bad effects are also considered Prasadam. Bhakti Yoga is the easiest with the main condition as once you surrender, there has to be no looking back without a shadow of doubt.
Arjuna had surrendered to Krishna considering him as Sakha. He din't have slightest doubt on his words (questions are different). He apologizes to Krishna after being overwhelmed by his universal form, thinking that he was being too candid with the supreme God!
An extremely sinful person if devoted to God is considered saintly/Sadhu. But the catch is that a person has to get influenced by "remembering God" continuously during his regular life to be able to realize the same feeling during death. Instantaneous generation of Godly feeling should be quite rare. If one rely on that gamble then bigger chances of failing.
In nutshell while Death
For Gyan-Yogi, he treats the life as a grand film and him being a character. The actors who play hero or villain are not punishable by the law! Rather the yogi is aware that he/she is not involved in any activity whatsoever.
For Karma-Yogi, being embodied it's recommended to act according to Swa-Dharma. Behaving natural doesn't have virtue/sin. Finally the soul doesn't have any Dharma and to let it merge within the supreme, one has to let go all the Dharmas (including Swa-Dharma) around it.
For Bhakti-Yogi, "God" is just interested in "Devotion" (i.e. not being indifferent). God neither creates the doer-ship nor actions nor its fruits. Whatever virtue/Punya or sin/Paap we commit, are just 3 modes of material nature Triguna — Sattva, Rajas, Tamas acting within themselves. Not only that, God even doesn't accept anyone's Punya-Paap.
"You must achieve liberation during your life time.
Even if you fail to do it during your lifetime, you must think of god at least at the time of death, since one becomes what he thinks of
at the time of death. But unless all your life you have been thinking of God, unless you have accustomed yourself to dhyana of 'God always during life, it would not at all be possible for you think of God at the time of death."
Read Sanskrit word by word translation to get real verse meaning
 BG 6.27 — The yogī whose mind is ﬁxed on Me verily attains the highest perfection of transcendental happiness. He is beyond the mode of passion, he realizes his qualitative identity with the Supreme, and thus he is freed from all reactions to past deeds.
BG 4.36 — Even if you are considered to be the most sinful of all sinners, when you are situated in the boat of transcendental knowledge you will be able to cross over the ocean of miseries.
 BG 5.10 — One who performs his duty without attachment, surrendering the results unto the Supreme Lord, is unaffected by sinful action, as the lotus leaf is untouched by water.
BG 18.12 — For one who is not renounced, the threefold fruits of action – desirable, undesirable and mixed – accrue after death. But those who are in the renounced order of life have no such result to suffer or enjoy.
 BG 9.27, 9.28 — Whatever you do, whatever you eat, whatever you offer or give away, and whatever austerities you perform – do that, O son of Kuntī, as an offering to Me.
— In this way you will be freed from bondage to work and its auspicious and inauspicious results. With your mind ﬁxed on Me in this principle of renunciation, you will be liberated and come to Me.
 गुरुर्ब्रह्मा गुरुर्विष्णुर्गुरुर्देवो महेश्वरः गुरुरेव परं ब्रह्म तस्मै श्रीगुरवे नमः
 BG 9.17 — I am the father of this universe, the mother, the support and the grandsire. I am the object of knowledge, the puriﬁer and the syllable oṁ. I am also the Ṛg, the Sāma and the Yajur Vedas.
BG 13.14 — Everywhere are His hands and legs, His eyes, heads and faces, and He has ears everywhere. In this way the Supersoul exists, pervading everything.
 BG 13.23 — Yet in this body there is another, a transcendental enjoyer, who is the Lord, the supreme proprietor, who exists as the overseer and permitter, and who is known as the Supersoul.
 BG 13.20 — Material nature and the living entities should be understood to be beginningless. Their transformations and the modes of matter are products of material nature.
 BG 3.35 — It is far better to discharge one’s prescribed duties, even though faultily, than another’s duties perfectly. Destruction in the course of performing one’s own duty is better than engaging in another’s duties, for to follow another’s path is dangerous.
 Don't have textual reference handy. However, TV series "Krishna on Shishupala" and "Mahabharata on Kamsa" has shown this concept in genuine ways. Here is one Quora thread which discusses this as "Shatru Bhakti".
 BG 18.47 — It is better to engage in one’s own occupation, even though one may perform it imperfectly, than to accept another’s occupation and perform it perfectly. Duties prescribed according to one’s nature are never affected by sinful reactions.
 BG 3.33 — Even a man of knowledge acts according to his own nature, for everyone follows the nature he has acquired from the three modes. What can repression accomplish?
 BG 11.41-42 — Thinking of You as my friend, I have rashly addressed You “O Kṛṣṇa,” “O Yādava,” “O my friend,” not knowing Your glories. Please forgive whatever I may have done in madness or in love. I have dishonored You many times, jesting as we relaxed, lay on the same bed, or sat or ate together, sometimes alone and sometimes in front of many friends. O infallible one, please excuse me for all those offenses.
 BG 9.30 — Even if one commits the most abominable action, if he is engaged in devotional service he is to be considered saintly because he is properly situated in his determination.
 BG 8.6 — O Arjuna, one who at the final moment gives up body remembering any idea whatsoever certainly achieves that, because being absorbed in the same idea for a long time.
 BG 5.8, 5.9 — A person in the divine consciousness, although engaged in seeing, hearing, touching, smelling, eating, moving about, sleeping and breathing, always knows within himself that he actually does nothing at all. Because while speaking, evacuating, receiving, or opening or closing his eyes, he always knows that only the material senses are engaged with their objects and that he is aloof from them.
 BG 18.66 — Abandon all varieties of Dharma and just surrender unto Me. I shall deliver you from all sinful reactions. Do not fear.
 BG 5.14, 5.15 — The God does not create activities, nor does he induce people to act, nor does he create the fruits of action. All this is enacted by the modes of material nature.
— Nor does the Supreme Lord assume anyone’s sinful or pious activities. Embodied beings, however, are bewildered because of the ignorance which covers their real knowledge.