If the money isn't returned by the end of the transaction, the whole transaction is cancelled as if it never happened. Flash loans are used for arbitrage and refinancing — and in many exploits, because they give anyone huge capital for a moment.
DeFi
Flash loan
In shortAn uncollateralized loan that must be borrowed and repaid within a single blockchain transaction.