The Gemara in Brachos (61b) recounts the story of R’ Akiva, who was jailed for teaching Torah to the masses. When it came time to execute him, and they took him from his cell, it was time to recite the Shema, which he did. As they scraped his flesh with iron combs, he accepted upon himself the Kingship of Heaven. His students were astounded that he could do this.
“My whole life,” he explained, “I have been pained over the verse, “with all your soul,” [which I explain to mean even if they take your life,] wondering when I might fulfill it. Now that I am able to, should I not do so?” R’ Akiva prepared himself every day to sanctify Hashem’s name, and he was ready when the moment arrived.
The Ben Yehoyada posits that this conversation actually took place before R’ Akiva was killed on Yom Kippur, for he could not have answered them during the verse of Shema. Rather, for 40 days prior, he had been taken out and his flesh scraped while he said Shema. They asked on one of those days.