This bug has been reported by many people. There's nothing much you can do other than as you said moving the bed, or dismantling it. However, you can use the EssentialsMod, which includes a stuck prisoner fix, that you can 'hire' from the staff menu which will remove the stuck prisoner (only).