Since there is no specification of How hot, I would answer based on some assumptions.
The phenomenon you face is quite normal. Whenever the temperatures of the components in the device get hot, to the point of possible hardware damage, the phone CPU goes into throttling. Have a look at this post about thermal throttling.
Basically, thermal throttling is when the CPU of the device reduces its power (clock speed and voltage). And due to this the device starts to cool down.
When its too hot (like well around 70 degrees Celsius). This will cause the device to throttle and slow the clock speed. Which in turn causes lag (or dropped frames) this affects the whole of the device (touch screen, GPU e.c.t.) and will speed back up once normal safe operating temperatures are reached.
Thermal throttling is controlled by the kernel. SO by using a modified kernel throttling can be turned off, but is defiantly Not recommended. This is a feature to prevent permanent hardware damage to the device.
This also explains why your phone functions normally when it cools down since that is when the processor returns to its "normal" mode.