Why would a firm stay open if it's losing money?
If price is above average variable cost and below average total cost and the firm is losing money why would it stay open? The firm can pursue other opportunities,why would it stay in a failing business?
The reason a firm stays open if price is above AVC but below ATC is because the firm is losing LESS money by staying open than it is by closing down. If they can charge more than AVC, they can pay all their variable costs and still have a bit to put towards their fixed costs. If they shut down, they still have to pay all the fixed costs.
BUT: the second part of your question brings up something very important.
The above answer ONLY applies in the short term. If a firm finds that it is not going to be able to do anything to get prices above ATC, it should, in the long term, shut down. In the long term it can get rid of its fixed costs by doing something like selling its machinery and buildings.
A firm may stay open, even if it losing money, in the hopes that it will gain money in the long run. In fact, it seems to me at least, all firms start this way. They put the money down and they have hope that in a certain amount of year they will be profitable. For instance, a relative of mine is in venture capital and he offers money with the hopes of great returns in the long run. In the short run, he may lose it all.There may be other reasons for doing this, but the best reason is that there will be profit in time. Now as for when that time is, no one knows. Also, things may fail, but many things in life require risks.