When the datasheet specifies Vgs, that's Gate to Source voltage. It's not absolute voltage relative to ground. If you've got 40 volts on the Source, and you couple that to the gate through a resistor, then 40 volts will also be at the Gate. Gate voltage (40 volts) minus Source voltage (40 volts) equals 0 volts for Vgs. That's well above the threshold voltage (Vth, usually something like -4 volts or thereabouts), and so the transistor turns off.
Vth tells you how much you need to lower the gate voltage, with respect to the source, in order to turn it on. So, for example, if you use the resistor I mentioned above, and create a voltage divider by connecting the gate through another resistor to ground, you can hold the gate voltage at a specific value. If Vth is -4 volts, then Vgs needs to be -4 or less. If you have a 1/10 voltage divider, it makes the math real easy here (for our example). 40 - 4 = 36. So pick your voltage dividers such that you get this voltage at the gate.
To turn it back off, you can insert a switch in series with the lower resistor of your divider, so when it's opened, the gate voltage rises back up to the source voltage, and Vgs returns to 0.