Now, I don't understand much about electronics. But could it possibly be a broken solder in the electronics contained in the head of the flashlight? Heat expands stuff hence closed circuit, cold contracts stuff hence open circuit.
Again... I don't really understand a thing about electronics...