Any artificial physics uses iterative calculations - work out force at this time interval, acceleration, velocity, increment position, work out force at next time interval, etc.
However - when very close to a magnet (or single-point force) the force and therefore acceleration can be huge. Say you're an inch away from the magnet accelerating towards it. Obviously in real life, moments later, you'd be an inch away on the other side and thus accelerated in the other direction by an equal amount resulting in overall equilibrium. However if we calculate this on a computer, by our next time interval we could be a mile away because the force is so strong at this point. As a result the object doesn't get an equal and opposite acceleration, and yes, gains energy. That at least is my best guess for what's happening here.
Solution would be to either set up the orbit so the object never gets too close, or work out the forces artificially using vectors and distance and put a cap on the maximum force (which you can do if you control the equation). I do this, and my objects aren't flying out into infinity.