You should check the engine emergency switch. One should be on the mitorbike side stand the other one on the right side of the steering (wheel?). first you can switch of, and ifor this helps not try to make a shortcut.

And try to switch the CDI unit with somebody who has the same engine Type.
I had something simmilar, my engine started and goes randomly off. It was the CDI module

I do not know what is this for valve. Can be that this prevents from gas flow if engine is off.