Anyway, does someone has some pointers as to what happened here?
It's hard to say what might have happened. There's a number unknown factors involved, so any answer you may get would be pure speculation.
And what can I do to prevent something worse to happen, like the drive not working after that.
This is the better question:
First, you might consider an UPS. A thinclient mini PC and an external drive would work fine on a smaller, less expensive, UPS.
Second, you might consider looking that the hard drive's SMART stat's for drive's age, health and other factors. Drives last between 5 and 7 years. (However they are known to fail sooner or to last longer.) SMART stat's will provide you with the age of the drive and indicators of developing problems.
Finally, if you really want to keep your data you need BACKUP. Of the things that fail most frequently in a PC, mostly likely, it will be a hard drive. So, if you want to keep your data, you need to duplicate it on another drive at a minimum.
You might consider reading the Backups and Backup Strategy section in this -> doc . It will explain a few concepts.