This engine uses a CDI ignition system. The problem can be one of a few things, and in order to figure it out you have to know how a CDI Ingition system works.
In a nutshell here is how a CDI iginition system works. CDI means capacitor discharge ignition.
The main components of the system are the flywheel, the stator coil, the pulser coil(also known as a trigger coil), the CDI box, and the ignition coil.
As the engine spins, magnets inside of the flywheel sweep past the stator coil and generate electricity. It makes anywhere from 100 to 300 volts AC. That AC gets sent down to the CDI box, where it is changed over to DC (rectified) and stored inside of a capacitor inside of the CDI box. After that cycle happens. The flywheel magnets sweep the pulser coil, and generates a small amount of electricty, anywhere from a 1/2 volt on up. That "pulse/trigger" signal then travels down to the CDI box. It activates a SCR inside of the CDI. A SCR is a silicon controled rectifier, it is basically a little switch. When the SCR gets the signal from the pulser, it allows the stored voltage inside of the capacitor to leave the CDI, and travel down to the ignition coil. All an ignition coil is, is a step up transformer. It takes the 100+ volts it gets from the CDI and steps it up to the 20K + volts needed to fire the spark plug. And then the cycle repeats itself over and over. Many thousands of times a minute. For every 1 rpm of the engine, the igntion system cycles as I described.
Now when a CDI igntion system is running (the engine is running) what happens when you want to turn it off is that you are grounding the stator voltage that runs into the CDI box. This is called the stop circuit. On the Yamaha, there is a white wire that runs out of the CDI box, and goes into the main harness. Up at the front of the boat, that white wire splits off to 2 locations. It runs to the emergecy stop switch, and it runs to the keyswitch. If you pull the emergency stop switch, or turn the key off, you are grounding that wire wire, shorting the CDI box, and stopping the engine.
What you want to do first is locate the white wire comming out of the CDI and first simply see if it has become disconnected from the rest of the harness. If it has, plug it back in and try it. If the wire is plugged in, what you want to do is unplug it, start the engine, and then take that white wire and jump it to ground. The engine should stop. If it does not stop, the CDI box is bad.
If the engine does stop, then the problem is 1 of 2 things. The white wire has a break in it someplace in the harness, or, ground is missing up front where the wiring for the keyswitch and emergency stop switch is.
That should get you going, and hopefully lead you to why its not shutting off. Now that you understand how it works, you should be able to find it if your just a little handy with electricity. 1 thing you want to watch out for is when the engine is running, there will be 100+ volts on that white wire. You want to be careful not to touch the bare wire. Touch the insulated portion of the wire or use plastic electrical pliers to move things around if you are not comfortable with electricity. There is not enough amperage on the wire to kill you. But there is enough voltage on it to give you a nasty shock.
Post back with any questions