Hi!
Yes, the stay inside issue is one of the worst problems you face. I wholeheartedly agree with Kagus' advice: Build outside walls so that archers can not shoot into your entrance area and make sure to trap/defend the area from which such attacks could be possible.
In addition, I want to point out a few other issues:
At least in 2D (I haven't had any sieges in 3D yet (^_^;; ), siegers will cheat. That is, they know exactly whether your doors are locked or not and where they are. If you close all the entrances to your fortress, the siegers will simply stop advancing and stay in position indefinitely waiting for you to open the doors again. In a certain way, it is like a real siege, but the issue that they do not even need to see the doors to know that they can't pass is quite annoying. As far as I can tell, that behavior still holds.
Another issue is to forbid all collectibles outside - if you order the dwarves to stay inside, outside items will still create tasks, causing you to get spammed with task cancellations. Especially when the siegers hit your defenses, all the loot will be tasked to be carried to the appropriate stock piles, drawing all hands to the front abandoning useful tasks. Thus, I think it would be best if you made sure to forbid all the equipment of the dead siegers the moment they die and claim it once the siege is finished. Also check the announcements for cancellations of store item in pile/bin because item in forbidden area.
Deathworks