All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
In reality, there is no evidence (in the Quran or Sunnah) that proves that a human being becomes aware of his/her death nearness, forty or sixty days before breathing his/her last.
From a practical point of view, most people do not feel such a state. Maybe there are some states in which a person becomes aware of the closeness of his/her death, but such a case is not restricted to forty or sixty days. Rather, most such cases come in the same day, or one or two days before one's death.
Some people are afflicted with abnormal anxiety. So, they think of the nearness of death, and the ghost of fearing death controls them. This state is from the devil in order to sadden a believer and drive him a way to despair. Thus, we are required to be ready to meet Allah, The Great and Al-Mighty, and to do more good deeds since death comes suddenly.
However, despair and fear are fruitless in this concern. Allah's fate is sure, so it is our duty to repent, to hasten in doing good deeds, and to avail ourselves of the opportunity in righteous actions.
We advise you to frequently mention Allah, read the Quran, and commit yourself to perform the five daily prayers in congregation. Such above-mentioned points, Allah wiling, will help you treat and drive away despair and fear.
Allah knows best.