A good practice drill for iPad users is swiping up from the center of the bottom of the screen and tapping the airplane icon. If you can do that in the time between an accidental gem purchase and the time your game synchs with the server, you won't lose the gems.