Laptop abruptly turns off after being powered on when battery is being charged

Jun 9, 2019
I have a 9 year old Samsung laptop that I haven't felt the need to replace because it works well for the most part and doesn't have any major issues. Since last year though, I have been facing a very specific problem. If I have the battery inserted and connected to power for charging, the system abruptly shuts off with a ping sound, a few seconds after starting up. This happens during the Windows loading stage. If I disconnect the battery from the laptop, and turn it on while connected directly to electricity, it boots up with no such issues. I should also mention that my workaround for this issue has been to power on the laptop on battery only, and when the system is booted up and running, turn on the power source to charge it and I'm able to use it without any issues. This happened even when the battery was new. Any insight about what could be happening? The laptop is running Windows 10, with 4gb DDR3 RAM and I replaced the battery last year, and the problem started a few months before that.