Car runs after main switch by battery is off

Sounds like your alternators output is not routed to the battery side of the switch,