----Fix is at the end----
It's been happening to me. My moto G4 plus would shut down when I had the brightness on max, recorded video, played loud audio, had incoming calls, etc.
I investigated a lot and everything pointed towards the battery. But the battery charged fine and lasted fine, and with the charger connected it would not happen. Tried recalibrating it but it didn't work. Then I downloaded an app which would show me the battery voltage in realtime. So I did some more tests. I tried doing power intensive things (flashlight, video, etc) and checking the voltage. When I was doing something power-hungry the voltage would drop to 3.2-3.1 volts, and then slowly rise up, which indicated the battery could not deliver too much current rapidly.
So I tought of two possibilities, the battery could be faulty, or the contacts were loose/dirty. And I did the easy/cheap fix to see if it worked, I just disconnected and reconnected the battery connector, and it worked like a charm, no more shutting down out of nowhere, even at 10% battery and with power intentive tasks.
TL;DR: If it happens to you, remove the battery connector and reattach it again. It worked for me. If it doesn't, replace the battery.