Your reasoning is totally correct according to Baldwin's Rule - the 4-exo-product would be more stable than the 5-endo-product ( see : This for more details).
But your method may be wrong in the given question the product A was first formed and then a ring closure step was performed using $\ce{KOH}$ as shown below :

here the 5-exo-trig ring closure is favoured according to Baldwin's rule .
Let me also address something that may be a doubt ( It was mine ) i.e. why doesn't the oxygen atom attack the bromonium Ion in the first step ? this is because even if it will attack you will also form a acid $\ce{HBr}$ which will cause the cleavage in the cyclic ester we just formed returning us to the original reagent hence it doesn't attack.