The past perfect with had is used to describe an action that has ended before another event took place... For example:
- I had made all my homework when the tornado ended.
- The tornado had ended when I went out.
- When I moved out, I had lived there for five years.
So regarding your question it's probably wrong to say had ended in this case because the ending of the tornado is the event that took place last... As in:
- "Everyone had been saved by the time the tornado ended."
Another use of had is the conditional. This describes hypothetical circumstances and speculations. For example:
- If I had been invited, I would have come.