There's an app for that. I mean, seriously. It's called demagnetizing the accelerometer. This basically allows it to either remain at zero, or points within 0 indicating little to no movement. Sort of like your typical EA programmer.
No amount of careful planning will ever replace dumb luck.