For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.
Now I want to write a little
This will probably get closed as not-programming-related, but you may want to check your BIOS setttings.
My Lenovo laptop does exactly what you're suggesting natively. There is a setting in my BIOS for beeping on power status change.