the odd part is that it seems to happen everytime when the battery is around 40%. when you try to turn iphone on, it says the battery is empty, but back at home, the battery has 40% left.
Apple likely uses more advanced battery management than this but usually the current % of life remaining in a battery is indicated by the voltage of it at any moment in time.
So lets take an example:
We have a battery ranging in voltage from 0-10V. And for simplicity lets say at 4V the battery is said to have 0% battery and 10V has 100% battery for the iPhone.
The device(iPhone in this car), requires a minimum of 4 Volts to operate hence it is the 0%.
Now at 25 Celsius(77 Fahrenheit) the battery, chemically, is operating smoothly and at 40% battery has a voltage of 6.4 and can continue to operate down to 4.
Now when you move it to -10 Celsius(14 Fahrenheit) the battery chemicals are getting cold and the electrons start to move slower. This now results in the voltage dropping proportionally. So at 40% your battery could now be reading 4 Volts, which is not enough for the iPhone to continue operation.
But above 40% it still has more than 4 Volts so it can continue to operate. That is why it always happens at 40% if you were to put it into a significantly colder environment it might always cut off at 50% since the drop would be larger due to the cold
It is not an easy task to estimate battery current state and a lot of assumptions are made in the above analogy to better explain what is happening but I hope it makes sense.