Hi coop42. Welcome to the forum. Throttle position sensors don't get out of adjustment on their own, in fact, on most cars you just bolt 'em on and you're done. The Engine Computer takes a reading from it at idle and puts that in memory. From then on, whenever it sees that same value, it knows it must be in control of idle speed. At any higher voltage, the computer assumes you have your foot on the gas pedal so it leaves engine speed up to you.
The sensor is fed 5.0 volts from the computer. There are mechanical stops on the sensor to only allow it to read between approximately 0.5 and 4.5 volts on the signal wire. Anything outside that range is unacceptable and will result in the computer memorizing a diagnostic fault code.
Three things can cause a defective condition. If the ground wire or ground terminal inside the sensor breaks open, the signal voltage will always be 5.0 volts; a defective condition. If the 5.0 volt feed wire or sensor terminal break open, the signal wire will always read 0.0 volts, another defective state. If the signal wire breaks open, the computer's circuitry will " pull" the voltage it sees to 0 or 5.0 volts to induce a bad reading while you might still measure the correct voltage at the sensor. A worn spot or speck of debris inside the sensor will cause similar conditions. Different Engine Computers have different strategies on how long the defective state must be present before it will set the fault code. Some set the code instantly. Other computers watch the readings for a while before deciding to set the code. While it's waiting and watching, stumbling or other running problems could occur.
When the battery is disconnected or run dead, the Engine Computer often has to relearn the lowest reading from the throttle position sensor so it will know when it must be in control of idle speed. Until that happens, the engine will often stall when you remove your foot from the gas pedal. The procedure is automatic but certain conditions must be met. Chrysler, for example, simply requires the engine to be warmed up, and you coast for at least seven seconds from highway speed, without touching the brake or gas pedals.