First thing you should check is the fuel pump and fuel filters. Clogged filters will cause engine to die. hope this helps.
If you are sure that all the wiring is ok, then check the fuel.
In my 1993 Altima, I've had that problem 3 times. Each time, it was the alternator. I used a simple voltmeter check to isolate the problem. Battery voltage should be 12-13 volts without the engine running. When the engine is running, that voltage should increase to 14-16 volts. If the voltage does not increase, your alternator is bad...( NOT! the battery won;t go past 12.6 volts....they dont make them to go that high!}
There are pages of things that will turn the check engine light on. You need to have it checked for codes.
to me it sounds like your map sensor is going out, you might want to check that.
check ignition
something wrong on the engine get it chek for any codes
Alternator not charging battery sufficiently? Check with a voltmeter: A fully charged battery should read approx. 12.8 volts without engine running. With engine running should read approx. 13.8-14.2 volts
If your alternator is good it should stay running until your engine dies from no fuel.
Check at the battery with a volt meter, Should have over 14 volts when engine is running. If not, possibly have to replace the alt. or check all the wires.
check for a vehicle theft system?? Is the Light Illuminated. does it stay on:::
the pump stays running as long as it needs to to keep the pressure up. If you think it should not, check for pressure leaks in the fuel system.
If your 1989 Mercury Topaz starts but won't stay running, you should check the fuel system, including the fuel pump, fuel filter, and fuel injectors. Additionally, check the ignition system for issues with the spark plugs, ignition coil, or ignition module. Finally, inspect the air intake system for any blockages or leaks that could be affecting the engine's ability to run smoothly.