Could well be I am wrong here, but the long press cannot be masked in software; it triggers a hard shutdown even in case where cpu is totally locked.
...all of which brings us back neatly to the weak battery contacts.