How much earlier/later is sunrise/sunset at 40,000 feet?
There's two parts to the answer.  One is the extra angular distance to the sun you get from altitude and the other is the time that it would take to traverse that distance.

For the angular distance, besides the surface geometry, there's some additional effects of refraction.  I'm going to ignore that on the assumption that there will be some refraction both at the surface and at altitude, so it will mostly cancel out (and it's harder to calculate it).

From the surface we see the sun cross a line of 90 degrees to the vertical (horizontal), from 40,000 feet it would be $\sin^{-1}(\frac{R}{R + 40,000 \text{feet}})$ or 86.5 degrees.  From altitude, we see around an extra 3.5 degrees.

The time you get from that extra distance depends on the season and the latitude.  If you were doing it over the arctic circle in december, you might get hours or days more sunlight. 

If you have time to look it up, check the civil twilight calculator for your location.  That's the time when the sun is 6 degrees below the horizon.  That means you'd see sunset at that altitude about the midpoint of civil twilight.

Otherwise, you can make a broad guess that most places in mid-latitudes have a civil twilight that lasts about half an hour.  So at altitude, you get about 15 more minutes.  Maybe a couple minutes more near solstices, a couple minutes less near equinoxes.