That all depends on how high the roof is in relation to the floor. If you have enough room, you could put in some poultry netting, allowing it to hang down enough that if they fly into it, they might bounce off. Or possibly pad the ceiling. If you have 5 or more feet from the floor to the ceiling, they can usually avoid the ceiling. Try to keep the quail in an area away from things that might scare them, like dogs, cats, or humans sneaking up on them.