Airlines don't have a policy about not hiring 40+. It is the market that stipulates this.
If there is a shortage of pilots then a 40+ is an option. If there is a surplus of pilots why should an airline hire a 40+ and get 20 some years of service, when a 20 something will give then 40 years of service. It's all about supply and demand.
Airlines do try to spread the age when it comes to hiring, since a few airlines have been punished when a large portion of the workforce retire at once. Happened, and is happening, at the moment. Currently, it is a blessing with the downturn but during an upturn then it is noticeable.
When I started training at my airline we had guys around 40 who were civilian (military is another story), so it's possible.