If your temperature gauge still operates when the ignition is switched off, as it does on some cars, you will see the needle rises after the engine has stopped. That is because it is measuring coolant temperature, not engine temperature. The engine is still much hotter than the coolant. Yes, the engine still puts out heat even when it is off.
You want to remove excess heat. The operating fan helps out by blowing fresh air past the engine. Perhaps there are some cars that, on very hot days, may even boil were it not for the operating fan.