כי אתא רב דימי א"ר יוחנן לא שנו אלא שלא בשעת גזרת המלכות אבל בשעת גזרת המלכות אפי' מצוה קלה יהרג ואל יעבור
(ג) וְכָל הַדְּבָרִים הָאֵלּוּ שֶׁלֹּא בִּשְׁעַת הַגְּזֵרָה אֲבָל בִּשְׁעַת הַגְּזֵרָה וְהוּא שֶׁיַּעֲמֹד מֶלֶךְ רָשָׁע כִּנְבוּכַדְנֶצַּר וַחֲבֵרָיו וְיִגְזֹר גְּזֵרָה עַל יִשְׂרָאֵל לְבַטֵּל דָּתָם אוֹ מִצְוָה מִן הַמִּצְוֹת. יֵהָרֵג וְאַל יַעֲבֹר אֲפִלּוּ עַל אַחַת מִשְּׁאָר מִצְוֹת בֵּין נֶאֱנָס בְּתוֹךְ עֲשָׂרָה בֵּין נֶאֱנָס בֵּינוֹ לְבֵין עוֹבְדֵי כּוֹכָבִים:
(3) And all these words are directed at a time which is not under pressure of arbitrary edicts, but at a time of arbitrary edicts such as when a wicked king, like Nebuchadnezzar and his associates arise and issue an edict against Israel to violate their religion, or one of the commandments, then he should die and not transgress even one of the other commandments, whether he is forced to do the transgression in the presence of ten, or whether the compulsion will be between himself and the idolater.
The Gemara raises a difficulty: But wasn’t the incident involving Esther, i.e., her cohabitation with Ahasuerus, a public sin? Why then did Esther not surrender her life rather than engage in intercourse?
it is taught in a baraita: In the case of the daughter of a priest who married an Israelite and her husband died on that same day, she immerses to purify herself, as she is ritually impure due to their intercourse, and she may partake of teruma that same evening? Evidently, the Sages were not concerned that she became pregnant from the initial act of intercourse, even that of marriage. Rav Ḥisda said: She immerses and partakes of teruma only until forty days after her husband’s death, when there is still no reason for concern, as if she is not pregnant then she is not pregnant. And if she is pregnant, until forty days from conception the fetus is merely water. It is not yet considered a living being, and therefore it does not disqualify its mother from partaking of teruma.
שו"ת אגרות משה חושן משפט חלק ב סימן עג
ובאמת לא ראיתי הנחיצות ליתר ביאור בזה, שלא היה מובן לי היכן ראה כתר"ה מקום ששייך לטעות שהרי הדין שכתבתי הוא דין מבואר ופשוט, שאם אין יודעין הרופאים שום רפואה לא רק לרפאותו אלא אף לא להקל היסורין, אלא להאריך קצת חייו כמו שהן בהיסורין, אין להם ליתן רפואות כאלו. שהרי בכה"ג חזינן מעובדא דרבי.
Responsa Igrot Moshe Choshen Mishpat 2:73
Truthfully, I do not see the necessity of elaborating this, for is was not clear to me where his honor saw a place in which one might err. For the ruling that I wrote is clear and obvious. For if the doctors know no cure, not only to heal him but even to reduce the suffering, they ought not to give such treatments. This is what we derive from the story of Rebbe.
שו"ת אגרות משה יורה דעה חלק ב סימן קעד
ענף ג. ובדבר שעושין הרופאים לקיים את מי שרוצים ליטול ממנו איזה אבר שיחיה אף שלא היה ראוי כבר לחיות ע"י אמצעים מלאכותיים עד שיהיה מוכן להשתיל בחולה, נראה לע"ד דכיון שאינו לרפאותו אלא להאריך חייו איזה שעה אם חיי השעה שיחיה ע"י האמצעים של הרופאים יהיה ביסורים אסור.
Responsa Igrot Moshe Yoreh Deah 2:174
Section 3. Regarding what doctors do to keep alive an individual whose limb they need to amputate, even though he would not have otherwise been able to survive without artificial means, until he is ready to donate an organ to another ill person, it would appear that since this is not to heal him but to extend his life for a short time, if that short time by means of artificial means will be with suffering, it is prohibited.
One who does not visit the sick cannot seek compassion for him, whether that he live or die: It seems to me that this means that there are times when one must seek compassion for one who it ill that they die, for example, when one is suffering from severe ailments and he will not live....[see story of Rebbi's death in Ketuvot 104]