If I remember right, I removed the shaft that connects the motor to the other side first.
Next, unbolt the nuts on top that attach to those little carriage bolts (which you already did).
Then, with beds removed (or the weight of them supported), I was able to pull up on the top bracket enough to pull the chains off the sprocket that is connected to the motor.
Whatever you do, don't let the chain fall down in the side track though. You'll have to pull it off the wall to fish it back up.
I remember this was a pain in the ass going back together because the chains sort of had to be timed correctly and evenly.