You need to be far more specific. It turns off and you need to switch it back on, or it comes back on itself after a while, or the power just blips out for a second or two... over rough ground, up hills, or at any time over any terrain... is it totally random or in sequence with other events eg. after a long period of riding... does everything die or just the motor assist... does the display stay on or die too? We're not psychic. You need to say exactly what is happening for someone to second guess a likely cause.however it randomly turns off when I am using the bike
First though, fully charge the new battery to a measured 42 volts, then take it for a ride and let us know.