Magnetic confinement of a neutral gas