a) You can stay on and try to work in the heat.
b) You can go home, have lunch, take a little nap and return in the evening when it's cooler.
Option (a) means you spend the next three or four hours in a zombie-like state with your brain addled by the heat and your productivity severely reduced. Basically, you will do no real work at that time, you'll just be filling your chair and pretending to work.
Option (b) is the optimal allocation of resources. You work when you're in your most productive and when you can't be productive, you don't work.
I'm speaking of very recent experience. I spent August and September in Greece, working on my PhD research(80% coding, 20% paper writing, should probably have been the other way around). I'd have lunch around 14:00, then go for a nap around 15:00 when the glycaemic spike would hit (often just from a bit of salad, but with lots of olive oil). I'd set my alarm to 15:20 to make sure I wouldn't oversleep. That's just a quick nap- but I would wake up invigorated and work 'till night time, when friends would appear unsummoned and drag me off to drink and celebrate life like only we in the South know how to [2].
____________
[1] "Very hot" is over 30°C most of the year, near 40°C in the summer (which lasts most of Spring and half of Autumn, too). That's _on average_.
[2] This is sarcasm.