Commuters on their way home from work have been told not to travel by train unless “absolutely necessary” as the heatwave grips Britain.