The thing with the flatnead slot is a nut. You cannot remove it while the bolt is inside it - so don't try turning it any more. Example below:

If you have (evidently) removed a nut and washer from the bolt in the recessed part, the rail should come free. It may need a light hammering on the headboard with a soft-faced hammer to get it to start moving.
The idea is similar to gnicko's answer but constructed quite differently. There should be no need to hack your way to the head of the bolt from the outside of the frame. With the nut in the headboard, there's nothing other than what you already removed holding the rail to the headboard.

The more normal use of these is with the nuts in the rail and the bolt being turned from the outside of the frame. I am guessing that the frame-maker in this case probably wanted to completely conceal the boltheads - as a result, you may have bolts you can't remove sticking out of the head and footboards when moving the frame. However, it's also possible that these are just threaded rods, and you can unscrew them from the nut once the rail is out of the way.