I would definitely do it with the engine off to be on the safe side. I'm not sure if it got screwed up because I did it with the engine running or if my cable dropped out mid-clear and corrupted data that way. Either way, theres no reason to do it with the engine running, so I would avoid it.
Check out my band - The Marked
1999 BMW 328i (Daily Driver) - m54b30 intake manifold, ebay headers, Rebirth Motorsports CAI, Rogue Engineering underive pulleys, Epic Motorsports Remote Dyno Tune, Custom 3 inch exhaust with Burns Merge, Schrick 264/248 Cams
1967 Buick Skylark - 430 Buick Big Block Swap.