I also had trouble confining my hens with a 4 ft fence, but clipping flight feathers and raising the fence by 2 ft kept them from flying out. It is a huge outdoor pen, so covering the top is impossible. I did find that it was necessary to eliminate any timber / wood top on fence sections or gate. Like a previous post stated, they'll fly up to perch on it before flying down. I extended light chicken wire up one foot over the top of the wooden gate to prevent this and it has worked beautifully.
The breed, age, and previous experience also has an impact. Heavier breeds, older hens, and those that have always been confined will be easier. Lighter more agile breeds, younger hens, and those that have free ranged will be more difficult to confine. Three of mine are in the first category and the other three are the second category. So far (and that could change!) I've successfully kept them in the pen - now the flower beds around my house have a chance to flourish this spring!