The crux of the matter lies in distinguishing the "perfect past tense" from the "imperfect past tense".
The tips given by Janileide and Francine are highly likely but not completely right. A small change of context already changes the verb.
Nós estávamos no Rio de Janeiro para o Carnaval quando veio o furacão.
We were in Rio de Janeiro for Carnival when the hurricane came ..
Ela não estava na escola hoje quando o furacão veio.
She was not at school today when the hurricane came.
Eles estavam em São Paulo quando o furacão veio?
Were they in São Paulo when the hurricane came?
The "imperfect past tense" is often called the "present of the past". It is the verb that transports you, in thought, to the past. Therefore all events associated with it can not be cloistered by a well-defined "temporal bubble" (in the imagination).
On the other hand, the "perfect past tense" implies a "temporal bubble" defined by context or description. This is why there is often a combination of the perfect tense and the imperfect tense.
Eu estava (transporta-te no tempo) em São Paulo quando veio um furacão (fala de um evento dentro de uma bolha temporal bem imaginável).
I was (it transports you through time) in São Paulo when a hurricane came (it speaks of an event inside a well-conceived temporal bubble).
Important note: do not confuse "imperfect tense" with continuous tenses. The continuous tense may be, in turn, either "perfect" or "imperfect".
Eu estive estudando das dez ao meio dia.
I was studying from ten to noon. (It is a continuous action but inside a time bubble)
Eu estava estudando calmamente quando o cão veio e me mordeu.
I was studying quietly when the dog came and bit me.
With very small modifications or none you can use "estive" in your sentences.
1. Eu estive com fome, e por isso comi um lanche.
2. Eu estive feliz durante as minhas férias. (You can use both...)
3. Depois da morte daquela menina, eu estive com muito medo por muito tempo e não entrava na floresta.