If your laptop is shutting down unexpectedly, one possible reason could be that the batteries are running low and need to be replaced. This is especially true if the laptop has been used for a long time without being plugged in. If this is the case, you'll need to replace the batteries in order to keep your laptop running properly.
To check if your laptop's batteries are indeed running low, first try plugging it in and seeing if the problem persists. If it does, then it's likely that the batteries are indeed the issue. You can purchase new batteries from most electronics stores or online retailers. Be sure to get the right type of battery for your specific laptop model.
Once you have new batteries, simply follow the instructions in your owner's manual on how to replace them. With fresh batteries, your laptop should now stay on as long as you need it to!