I'm having the exact same problem.
Here's what I found, as I have troubleshooted myself, since I have tried new batteries, and the batteries show a good charge on a volt meter, it's not the batteries, but the contacts themselves. It's almost like a capacitor that wasn't rated high enough was used, so the sudden shock of just moving it sometimes, yields it to power off. A capacitor that was good enough would have filtered this ripple.
I've notied this a lot lately, Apple has been using underrated capacitors. I don't know if this is Apple or Foxconn (if they make the magic mouse) fault, but it's a big problem for yours, and mine at least.
I might need to come up with a thing to force the batteries to not move..