The check engine light came on at 40,000 miles. on 2004 Mercury Grand Marquis

Is the check engine light triggered at 40,000 miles, and if so, how do I turn it off?

Just go to a part store and have them give you a free code read and post the results here.
1 more answer
i think something wrong with your engine,
you should get a car diagnostic tool for your car,
maybe this tool can suit for your car,