How to stop the cayenne.loop() when there is no wifi?

you can give Online/offline code a try.