How do I remove a bolt that's stuck in a ceiling junction box?
While cutting off the bolt is definitely a good way to handle this situation. Here are a few things to try, before you take the destructive route. It also sounds like we might be having a bit of trouble with terminology, so I'll start with some definitions.

As you can see, the bolt is the bit that looks like a screw, while the nut is the bob that twists on to the bolt.
With that out of the way, let's look at some ways to remove a nut from a bolt.
Lube
Give the nut and bolt a health dose of penetrating oil, and let it soak for a few minutes (see manufacturers instructions). The oil should work its way in to the threads of the nut and bolt, and possibly lubricate the connection allowing the nut to spin free.
Put pressure on the bolt head
If you can get a flat head screwdriver, or other flat object behind (under) the nut, try prying while you turn the nut with pliers or a socket.  The downward pressure will pull the bolt head against whatever it's resting on, which may prevent it from rotating with the nut.
Pull and twist
Try using a pair of slip joint, tongue-and-grove, lineman's, or other pliers to pull and twist the nut.  This follows the same idea as the previous method, which is that the downward force will prevent the bolt from rotating and allow the nut to spin free.
Spin the bolt, not the nut
If there is enough of the bolt available below the nut (and you can get a small saw in the area), you can try to cut a notch in the bottom of the bolt. This will allow you to use a flat head screwdriver to turn the bolt, while you hold the nut stationary with a pair of pliers.
Hold the bolt steady
If you can grab hold of the bolt, you may be able to prevent it from rotating while you twist the nut off.  In your case, it doesn't look like you can grab the bottom of the bolt, but you might be able to grab the top.  First you'll have to remove the knockout at the back of the box.

Next use a pair of right angle needle nose pliers, to reach up through the knockout hole and try to hold the bolt stationary.

Once you've got a good hold of the bolt, you should be able to spin the nut free.
Cut the bolt
By this time if the bolt has yet to shed its nut, you're probably adequately frustrated. So now it's time to take out some of that frustration, and cut the bolt.