The battery is actually a collection of cells and it's possible that one of the cells has failed in a way that doesn't accurately reflect in the meter of charge remaining. I have the same issue, also a 2013 MBP, and it will shut down sometime between 20-30%. I don't stress it with tasks like video editing at the moment, but if I did it would not surprise me to see that 30% figure rise even higher.
So I think a failed cell is the most probable cause.
The easiest way to confirm is to see if it still happens when the laptop is connected to the power supply. If it behaves well on the power supply, I would take that as the best evidence.
To double check, you could open the console and search for all occurrences of when it unexpectedly shut down and confirm it only happening on battery, but that may be a bit time consuming. If you know scripting that would make it quicker.
Further explanation:
Batteries are actually very complex; with chemistry, engineering, electricity, electronics, pressure and general physics all playing a role.
You can read here the many reasons why batteries fail
As an example of how this could play out to produce what we are experiencing, consider the following:
- A failing battery causes pressure build up
- Pressure causes heat
- The heat causes higher discharge (depleting the battery more quickly)
- The higher discharge rate fools the meter into thinking it has higher remaining capacity than it does (hence the false capacity reading)
- Stressing the computer with more demanding work produces additional heat, accelerating the cycle.
- And possibly, if the battery interprets this as a risk of thermal runaway the safety circuits may then shut the battery power down immediately.