Simple cure, just don't leave it running on the sidestand!
If it were dying immediately when you put the sidestand down, I would say look for an interlock (safety switch), but that isn't the case. Will it sit and idle if you hold it upright? Will it idle if you hold it leaned to the right?