Note: the below is a UK perspective, some of it may also apply elsewhere but details are likely to vary.
Cards can be used offline and even without electricity but the fraud/overspend risk is higher and this can lead to restrictions on use or even the merchant to refuse to accept them altogether.
AIUI for chip and pin the card issuer sets a limit (which can be zero if the card issuer thinks you are a poor credit risk) for offline transactions to mitigate fraud/overspend risk and they don't usually tell you what said limit is in advance. For imprint and magstripe transactions I belive it's down to the merchant (and possiblly their bank) what transactions they are willing to risk taking offline.
If you have already eaten the meal/filled your fuel tank/got on the train then the retailers choice may come down to taking the card offline (and possiblly reverting to magstripe to get around the offline restrictions on chip and pin, I've seen that happen on a train before) or taking an IOU. The card is a lower risk than the IOU.
On the other hand a normal retailer is in a very different situation. If they decide they don't want to take cards offline and/or in a power cut either because they think the risk is too high, or for power cut scenarios because they don't want to bother stocking card imprinters and training their staff how to use them then you are SOL.
Also IIRC in the UK automated vending machines are restricted to online chip and pin transactions only. They are not allowed to do swipe and sign transactions or offline transactions.
So don't rely on your credit/debit card working in an offline/power cut scenario.