The Buddha taught the Dhamma up until his last breath.
In pain and discomfort, mostly likely from eating spoiled hog’s mincemeat, the Buddha went to the sāla tree grove at the turn into Kusinārā. A couch was made ready for him. He lay down in the lion’s sleeping pose as the miraculous blossoms on the sāla trees showered him out of veneration. Heavenly flowers and heavenly music played, all out of veneration for the Blessed One.
Before the Buddha attained Final Nibbāna, a wanderer named ‘Subhadha’ heard that the Blessed One would pass away before the night was over. Having confidence in the Buddha, Subhadha went to him looking for instruction in the Dhamma. The Blessed One instructed Subhadha right then and there.
Subhadha was encouraged and roused by the Buddha’s talk on the Dhamma and he requested the going forth. The Buddha agreed and instructed Ānanda to give the ceremony. Subhadha was the last to be given the going forth into the Sangha of bhikkhus and bhikkhunis during the Buddha’s life.
The Buddha then asked the Sangha of bhikkhus and bhikkhunis if there were any doubts or questions regarding the Buddha, Dhamma, or Sangha. Silence prevailed. The Buddha asked a second and a third time. Silence prevailed. He then instructed the Sangha to have a friend present their doubt or concern for them, if they were afraid to ask themselves. Silence, again, prevailed.
At this, the Buddha addressed the Sangha thus: “It is in the nature of all formations to dissolve. Attain perfection through diligence.”
With this final teaching, the Buddha entered into a deep meditation, progressing through all the meditative states, until his attainment of Final Nibbāna.
(Note: This brief retelling of the Buddha’s attainment of Final Nibbāna is taken from Bhikkhu Nānamoli’s The Life of the Buddha, pages 309 – 324.)