From Anna Key's "ritual biography" of the "merry monarch" Charles II,
The Magnificent Monarch: Charles II and the Ceremonies of Power, p. 205:
...The king murmured contrition; but when they [the Protestant royal chaplains] started trying to administer the sacrament, he waved them away.
On Thursday, the Duke of York [the future James II, and a Catholic], who had been constantly on hand, was told the king, now barely conscious, would not last the night. The duke slipped out and set an extraordinary sequence of events in motion. At about seven that evening the crowds of doctors and divines were ushered out of the bedchamber, and one of the queen's Catholic priests, the same Father Huddleston who had helped the king hide from enemy troops after the battle of Worcester, was brought up the back stairs. Two Protestant noblemen, the head of the bedchamber the Earl of Bath, and one of the Gentlemen [of the Bedchamber], Lord Feversham, remained to watch as Huddleston gave the king Holy Communion and received him into the Catholic Church. It all took less than 45 minutes. [...]
To most commentators, past and present, Charles II's deathbed conversion was deeply puzzling. Compared to his predecessor and successor on the throne, he had shown little personal religious conviction in life. [...] Perhaps Charles II had always harbored a spiritual commitmnent to Catholicism, hidden deep beneath the husk of disinterest and suppressed for reasons of state. Much more likely, paralysed with pain and with life slipping from him, he agreed to do what his brother, his wife, and his mistress must have all been urging. Confronted with his own death, it may have been a real epiphany, his one genuinely spiritual experience. Or perhaps, as in exile, he was simply adjusting to circumstance, and readying himself for whatever opportunities this last ritual might offer. We will simply never know.