Function that runs only when dragon is killed

Is there a way to create a function that runs ONCE only when the dragon is killed?
Continue to help post