Probably doing a DPF regeneration which on a very hot day can bring the fan on or the fan sensor is faulty
On my previous car, it was doing a regen as I finished a long journey. I was in France and the outside temperature was 30°C+ and the fan ran for a good ten minutes after I turned the engine off! I did wonder what that would do to the battery but no problems.