It's not an off-the-shelf answer, but look around for wiring diagrams on the "Retained Accessory Control" ciruits for some newer cars. This is a curcuit that keeps the accessories on, even though you have turned off the car. Then, they shut off accessories once the door (or some other trigger) is opened.
I have this on my 07 Grand Cherokee, but don't have the details on how its wired. I know i've seen it online somewhere.