If your MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports) randomly turns off when it still has a charge, these steps might help:

If your MacBook Pro's battery is less than 90 percent charged, continue to step 2. If your battery is more than 90 percent charged, use your computer until the percentage drops below 90 percent, then continue to step 2.

Connect your Mac to its power adapter. Quit all open applications. Close your computer's lid, which puts your Mac in to sleep mode. Let your Mac charge for at least 8 hours. After 8 hours, update to the latest version of macOS.

If the issue persists after updating to the latest version of macOS, contact Apple.