If it pops off when pedalling, it's because the chain is being backfed from the wheel towards the motor, which puts the pulling torque on the *bottom* of the chain, and loosens the top of the chain. That's the opposite of what the motor does when it is running, and what your tensioner is there to help with.
But even with that, if it's all aligned perfectly, the chain still shouldn't come off. If it appears perfectly aligned when the bike is stationary, and stays on whether pedalling on the trainer or motoring, then it probably is aligned fine there but is flexing under some circumstances on the road.
FWIW, that is a lot of extra chain to deal with. Is there any way you can reverse the reduction setup, so that the motor is in front, and the freewheel/jackshaft in back, so that the chain can run directly from the freewheel to the rear chainring on the wheel? If you do that, and eliminate all the extra chain length, you can also get rid of all the tensioners/guides for it. Just make the mounts that hold the whole reduction drive with sliding slots for the mounting bolts, so that you can slide it forward to tighten the chain and then secure the mounting bolts.
This will also make it quieter, and perhaps a bit more efficient, powerwise (though maybe not enough to see a difference).