Ironmage said:I don't have the decompilation handy, but it seems pretty self-explanatory. When the battle ends, the game needs to check how it ends to know if it should despawn the roamer or not. Exit via roar either mistakenly has the despawn flag enabled like catching or KOing does, or (in my opinion the more likely scenario) it lacks the flag to keep the roamer around like either party running does.
Though something to remember about this is that this is only a glitch in the Western Versions. In Japanese versions if Entei or Raikou used Roar they'll still be roaming.
This still can work with what
Ironmage said. I somewhat agree with their opinion that Roaming Pokemon have a flag which designates them as currently roaming; however I think that when you encounter them the flag becomes disabled and needs to be reenabled if the Roamer runs away (I think GF would prefer this approach as, incase a glitch happened, it's more likely the flag will remain disabled (thus no more will spawn, sucks for the player but the player could always reset in such extreme cases) instead of the flag remaining active thus giving letting players catch multiples of the same Legendary). Since GF decided to
be jerks make things more challening by giving them Roar to circumvent trapping Moves, they had to specifically program that Roar and Whirlwind reenable the flag (if you're wondering about Teleport, it's considered Running Away which reenables the flag). Once you catch or defeat them that's when the flag is left disabled (it won't be until Platinum that entering the Hall of Fame respawns KOed roamers).
Translating a game from one language to another has many nuances, one being you need to make sure any translation done in one place in the code is carried out throughout all the coding; and that's when oversights can easily happen. This is only a hypothesis, but my guess is when they translated the code for Roar and Whirlwind they didn't realize the roamer's flag had exceptions programmed in for those Moves that the translated code has now disconnected. Thus, when they use Roar or you use Whirlwind on them in the Western versions, the flag isn't reenabled and thus they're permanetly lost.