I do not think that's the reason. Mine was cutting out in different situations ,sometimes when I was going down the hill and not pedalling at all.
I inserted 2 small bits of foamy rubber under the battery in its ledge and the problem has disappeared completely.
Battery loses contact at times and...