Susan Boylston Adams Clark wrote a letter to Abigail Louisa Smith Adams Johnson (dated 9 July 1826), which which she describes John Adams' last hours. This was among the remembrances:
The family was all assembled in the Chamber, and as Thomas and myself were sitting on the bed we heard him whisper “Thomas Jefferson survives.”
That's my transcription of the photocopy they sent me, but her handwriting is actually pretty easy to read (it says don't reproduce, hence I'm not scanning in my photocopy, which would be pretty poor anyway with the double copy). So those as some of his last words have their basis in fact. Just saying.....
Now why they died on the same day...there are lots of possible reasons for that, even just coincidence. This is an interesting piece on that topic:
Each of these six explanations for the same-day deaths of Adams and Jefferson is inadequate on its face: the coincidence is too great; divine intervention requires background theological assumptions beyond the scope of rational explanation; “hanging on” and “giving up” require pathophysiological assumptions not well understood; and the various forms of direct-causation explanations, including inadvertent or deliberate allowing to die, physician or family-performed euthanasia, and suicide, all suffer from a lack of compelling evidence. It isn’t necessary that the explanation of the cause of death be the same for both Adams and Jefferson; yet whatever each explanation involves, it must attend to the remarkable synchrony of their deaths.
Furthermore, the issue of synchrony—whatever the individual explanations for their deaths—also leaves us with the further question of coordination. Did Adams and Jefferson think alike but act independently? Could they have had some joint understanding, reached perhaps in 1813—when each had been corresponding with a physician, Adams with Benjamin Rush about a horse’s deliberate stumble and Jefferson with Samuel Brown about lethal drugs—that they then recalled later on? Did their physicians or families think alike but act independently, or perhaps in concert? Could their families and caregivers have lied about the precise dates of their deaths, seeking to lend their demises a greater grandeur? Or was there a more orchestrated plan here, known only to these two men or to their physicians and families, that accounts for the extraordinary “coincidence” or “grand design” of their deaths? Could it have been the mode, so to speak, to die on the 4th if at all possible, by whatever means? After all, not just Adams and Jefferson, but three of the first five presidents of the young United States died on the 4th of July. In 1831, just five years after the deaths of Adams and Jefferson, James Monroe, the fifth president, did so as well.
Given the insufficient historical evidence available, we can’t know the truth about why Adams and Jefferson died on the same day. But we can reflect on whether it would make a difference to us if one or another of these explanations turned out to be true. After all, the six possibilities these explanations raise are central to the very questions about death and dying that are so controversial today: disputes over withdrawing and withholding treatment, allowing one to die, the overuse of morphine, terminal sedation, physician-assisted suicide, and euthanasia.
Two quite different postures are in competition in these disputes. One insists that the patient play a comparatively passive role in accepting death when it comes—whether it is explained as the product of divine intervention, sheer coincidence, or failure to hang on. The other casts the patient in a potentially active role, as the intender or designer or cause of his own death, whether he deliberately gives up or actively brings about death. Where we stand with respect to these two basic postures may influence how we explain the deaths of Adams and Jefferson.