Had exactly the same problem today. Bike has been laid up for a couple of weeks as awaiting my new exhaust system from
@Paul Bryant ...it's in the post now.. Fitted some cheap Chinese thingy just for the Mot. Bike started, reversed out of shed, bike cut out. Tried to restart and just a loud click.??? What?? Battery was shagged even though it's been on an optimiser. Removed battery and its was 10 years old.. Tested it with a battery analyser (perks of my job to have one lying around) and the voltage was low and current capacity was nil. So you cannot polish a turd, no matter how good the optimiser maybe. Might be the same issue??
Edit: Thinking about it, I presume you have tried the obvious - loose terminals on the battery??