A O- is a fairly good nucleophile, it can react intramolecularly pretty easily. Those Br+ and Cl+ ring structurs are actually highly unstable, in this case the epoxide is actually quite stable.
On a related note, I wonder why they used KH instead of the more conventional NaH.