How do I cap the wires in this electric smoke alarm?
All three wires get capped separately with wire nuts.  You need to cap the neutral (white) wire because it can carry current from another part of the circuit.  Wrapping the nut in electrical tape is a good idea too.  They make nuts that are good for holding a single 12-gauge or 14-gauge wire (the ones I have are dark blue).

You don't need to do anything special with the ground wire, just be careful when you're pushing the other wires up into the box that you don't accidentally touch it to bare copper on one of the other wires.

Also remember that electrical junctions have to be accessible.  In your case, this would probably mean covering the hole in the ceiling with a blank face plate and installing the battery-powered detector somewhere else: I don't think you can use the base plate for the new detector as the cover.  I would also be concerned about drafts through that hole reducing the effectiveness of the detector.