The shouting is the action that broke your stealth, so at the end of -that action-.
It's pretty simple, actually. If you do action A that breaks hidding, and you do an action B, C, or even D, you lose the benefits at the end of action A.
That's the common sense DM-at-the-table solution - and that's fine. But it's
not true that it's the shouting that is somehow the "first" action that broke stealth.
The moment the rogue steps into the room and loses all cover, he's breaking stealth. Then, he moves a few more squares - retaining the stealth benefits, despite having broken stealth. Somewhere half-way, he shouts - this would also break stealth, and stealth benefits are retained until the action completes. Then he continues his other action, which... retains stealth benefits until complete? Why not?
The point is, if the idea is that you retain stealth benefits
during the action because "it all happens so fast", then whether or not you made a noise half-way is beside the point - you probably made a
bunch of noise while moving anyhow, and you're in full line of sight so the noise is beside the point. Also shouting doesn't slow you down or somehow invalidate the argument that the movement resolved before people could react.
So, both from a RAW perspective and from a common sense perspective it's not unreasonable to say that
both actions break stealth, and
both actions retain stealth benefits until the action completes. After all, there's no rule that says you don't retain stealth benefits just because some other action interrupted yours - the rules just say you retain the benefits for the duration of that action.
Finally, you chose to go with the "shouting" example, but this could just as well have been another, less obvious, free action such as the warden's mark: It would still be an action out in the open (so why does it have stealth?) but the action itself needn't intrinsically break stealth.
I prefer the approach whereby the details of interrupts don't matter. In other words: the free action for shouting ends stealth but that doesn't take away the benefits that are retained while your first action completes.