Q. Is there a source to the minhag that some have to perform a ceremony of Hatarat Nedarim,when a person is a goses or moribund and about to pass away? This is done for the purpose of absolving the dying patient from all vows and promises done in his lifetime? Should it be done?
A. Some Poskim (Pnei Boruch 7: 15, quoting Maavar Yabok and others), do mention such a tradition.
The source to that minhag may be from the Talmud Niddah 30b. It informs us that "An unborn baby does not leave the womb until the angels administer an oath to it, as it is stated: “To Me every knee shall bow,” this is referring to the day of one’s death, “Every tongue shall swear;” this is referring to the day of one’s birth." The Talmud then adds "What is the nature of the oath that the unborn baby is made to take? Be righteous, and be never wicked."
If the Talmud is trying to teach us about an oath taken at the very beginning of life, why does it mention the day of death? The reason is simple; that departing individual is about to stand in trial, and without doubt, he will be questioned if he kept that original oath taken before he was born.
Horav Shlomo Miller's Shlit'a opinion is that, even for those who maintain this minhag, it should be done if the patient is conscious and understands the declaration done."
Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit'a