Magnetars in the Metagalaxy: An Origin for Ultra-High-Energy Cosmic Rays in the Nearby Universe