farewell poem; death poem
A poem composed when one is near death, often reflecting on life or expressing final thoughts. Strongly associated with Japanese literary and samurai tradition.
He died leaving behind a farewell poem.
Composing a death poem was a samurai tradition.
From 辞世 (farewell to the world) + の + 句 (verse). The exact historical origin is uncertain, but the practice is well-known from Japanese literary and warrior culture.