If the engine runs in neutral and stalls when you select a gear, check the side stand and clutch interlock system. But if the bike also lurches forward, the clutch may not be disengaging fully.
What is known from experience
Owners found a broken sensor pin, loose fasteners, a wire chafed through at a bend and a wire damaged by the chain. Contacts and connectors produced similar symptoms. The wire colours from one report don't guarantee a match on another batch.
How to tell the causes apart
With the engine off, inspect the sensor's mechanical actuation and the harness along its whole accessible length. Check the connector, the wire slack as the suspension moves and its position near the chain. Electrical checks are done using the diagram for your version, without bridging random wires.
Checking the result
After the repair, the system must respond correctly to the stand being up and down. A permanent bypass removes the protection against riding off with the stand down and isn't a repair of the assembly. If it happens again, keep looking for the cause.