So to add, a couple questions:
Are you brewing extract, partial mash or all grain? Mort and the others are spot on of course:) There are a lot of variables pertaining to attenuation, especially if you are brewing AG.
Aeration is also a biggie as that's what the yeast need once they hit the wort! Otherwise, freshness of ingredients, mash temps, etc come in to play..........
BTW, you mentioned 1.040 as where they are sticking? That's pretty high, are you by chance using a refractometer for your FG readings? IF so, I suggest using a calibrated hydrometer. Even with proper conversion refractometers are less than reliable when confirming FG readings.
Edit: Jim got some of this in before I finished typing:)