Mr Gooch,
You will need to go through a process of elimination. If you can recreate the problem, every time and MAKE it do it and KNOW it will do it EVERY time, then you are a long way to solving the problem. This is true with any problem solving. For instance.
Is the problem a short out? To eliminate this, when your loco is stalled, does another loco work on the same track? If it does then the problem is not a short.
For instance, there may be a loose connection in your loco, and when the bogies are at a certain angle to the chassis, the loose connection cuts power.
So you have determined the headlight goes out at the same time. And EVERY time it stalls, the headlight goes out. So it's not just the motor. Will it stall EVERY time, with the case on or off. Then it's not the case causing a loose connection.
When you loco stalls, will it ALWAYS move off again, with a touch to a specific spot. If so you will need to examine VERY closely, what moves when you do touch it in that spot ONLY.
Do you have a multimeter?? (One of the most useful model railroad debugging tools I have)
While the loco is stalled, determine how far through the loco wiring the power is available. (firstly, the lugs on the motor, then one lug to the other wheel etc).
I know, it is a slow and tedious process, but you will find out what the problem is. Once you know what the problem is, it's very easy to fix. Finding out what the problem is, 90% of fixing it.
Here is something to try. Get a 12 V light globe. (grain of wheat or something)......
1. take the case off the loco.
2. get the loco to stall and leave power on to the tracks.
3. touch each wire of the globe to each rails just in FRONT of the loco. Does the globe light?
4. touch each wire of the globe to each rail just BEHIND the loco.
Does the globe light?
5. If so, then sufficient power is available, and the problem is NOT the track, or power supply.
6. Touch the wires of the globe on the TOP of each wheel on each side. Does the globe light? If yes, the power has got as far as the wheels. If the globe does not light, then touch one track and the other wheel. Does the globe light?
7. Touch the wires of the globe on each "brush plate" on each side of the loco. Does the globe light? If yes, the power has got as far as the brush plate.
8. touch the wire of the globe on one "brush plate" and then follow the wire from the other "brush plate" and touch the connection at the end of the wire. Does the globe light?
9. and so on and so on.........
It's matter of process of elimination, to determine where the problem is.
If the loco moves off while you're doing this, then you will need to start again, when the loco is in the "stalled" condition.
It's no use trying to determine the problem, while the loco is NOT in it's stalled condition, as the problem probably does not exisit.
Hope this helps with your problem.