Hi ThanhMinh,
Thank you for reaching out Microsoft Community. We apologize for the inconvenience this may have caused you.
To help you out whether the issue is hardware or software-related, we would like to know if there were any updates installed before experiencing this issue. Is it going to shutdown whenever you removed the charger from the Surface? If your device shuts down after removing the charger, this could be a hardware issue but if it only happens when you detach the keyboard, then this could just be a software issue related to the device battery drivers.
To initially fix this issue, you may run the following steps below if you haven't performed it yet.
Method 1: Run Surface Diagnostic Toolkit and check Windows Update
Method 2: Update drivers and firmware
Check what is the current OS Build of your Windows version by going to Settings > System > About.
Go to Download driver and firmware for Surface, choose Surface Book then click Download on the next page.
Choose the .msi file that matches your current OS Build or the closed OS build available and click Next.
After downloading, run and install the .msi then Restart the Surface.
Method 3: Uninstall/Re-install Drivers
Open Device Manager
Expand Batteries
Right-click on battery drivers available and select Uninstall. If there is more than one driver, uninstall those as well.
If there's any pop up that will ask you put a check mark, just leave it blank and simply proceed uninstalling the drivers. After clicking uninstall, restart your device.
If this helps, please let our Community know by marking this post as answer. Otherwise, don't hesitate to respond to this thread for any further assistance needed.
Kind Regards,
Crest_Z