As per Bhagavad Gita whatever your thoughts are through life will be your thoughts at the time of your death and whatever thoughts are there at the time of your death will be your thoughts in your future birth.
Bhagavad Gita says that the best time to die is Uttarayana, before full moon, in day time or in the presence of Yagna. Does that mean the people who die in Dakshinayana or 15 days before Amavasya or during night will suffer and will not get liberation or they will go to the hell?
No. If this would have the intention, Bhagavad Gita would not have mentioned it at all as this would have created unrest in 50% of the society.
What they probably meant was that everybody at the time of death should be in a positive frame of mind. If they are not, efforts should be made to create positive frame of mind for them which means that if a person is dying in night or 15 days before Amavasya, one can create an atmosphere of Uttarayana or full moon by creating enough artificial light as if it is day time, doing Yagna in the vicinity of the dying person and or enchanting of any religious Mantra, for example, Gayatri Mantra in the ear of the dying person.
Efforts should also be made to talk positive in his or her presence. Ayurvedic or Homeopathic consultants can be contacted if they have any medicine which can convert negative state of mind into positive state of mind.
In the process of death a dying person can hear till his last karma indriyas and gnana indriyas are functioning.
In Hindu mythology, chanting of Rama or Aum at the time of death does the same thing.