The UK is set to welcome fresher conditions on Sunday as a record-breaking heatwave gives way to cooler temperatures and sporadic rain.