We've been dealing with this for about 4 months now (though things have improved dramatically!) It's definitely something about the age and testing boundaries, especially at night, because they are so curious about what we're up to (case in point-- when DH works late and it's just me, we have a huge decrease in bedtime battles-- not much is going on if it's only me there!). What we did was make clear rituals and rules. We follow our bedtime routine to the letter. She gets one visit to the potty once she's tucked in(this is a favorite excuse for getting out of bed). I actually didn't make any rules about getting out of bed, just coming out of her room, and for a long while, she'd open all her drawers and change her pajamas about 100 times.
But that has stopped, too, probably because I didn't make an issue of it. I also figured out that her bedtime needed to be adjusted-- now she goes down at 8, no earlier, no later. If it's too early, she isn't tired enough yet; if it's later, she's overtired and has gotten her second wind, and then it could take an hour for her to go to sleep. I also make sure to get her up by 3 from her afternoon nap, or otherwise we'll have resistance at bedtime because she's not tired yet.
DD's door has always been closed (we live in a small apartment and I've always closed it to cut down on light and noise from the living room), so closing the door wasn't going to be a reasonable consequence. I may be flogged for saying thsi here, but we put a door-knob cover on her bedroom door so she couldn't open it. Now that she no longer comes out of her room without asking, it has come off, but we were at the peak of this battle right after DD2 arrived, and I needed to do something so I wasn't chasing her down the hall all night and we could all get some sleep. I also had to start telling her that she would get only one visit from me or DH after she was tucked in, and then she would need to be in her room alone. We're finally coming down the other side and bedtime is getting more manageable. But 2 months ago, with a 2.5-year-old battling bedtime and a one-month-old who would not settle, I was going nuts! Hang in there, and be consistent with whatever you decide, and things will eventually improve.