a. Sidestand kill switch? I had an ST4s that at times would not start, even with sidestand up. Evoluzione makes a replacement part for about $35.
b. Had you just fuelled up? You may have gotten a load of water from your gas up, which will at times fill the fuel filter and cause shut down. ( Had this happen in middle of bum cluck nowhere northern Wisconsin with zero BMW knowledge-r11gsa)
Another common problem with these is just plain old electrical gremlins. Lift tank and go through the connections one at a time. Clean connection if corroded and put a coat of dialectic tune up grease on male and female parts, re-connect.