This boils down to the rate of (i) the intramolecular (ring-forming) reaction being faster than that of (ii) the intermolecular (polymerisation) reaction.
The rate of (i) will be governed by the rate law d[ring]/dt = k[monoalylated intermediate], and is clearly first-order since the reaction is unimolecular.
The rate of (ii) will be d[polymer]/dt = k[monoalkylated intermediate][malonate] or k[monoalkylated intermediate][dihalide] - so this reaction is second order.
In the case of competing first order and second order reactions, one way to favour the first-order one (the cyclisation) is to run the reaction at high dilution, since the rate of the second order reaction will fall in proportion to the square of the concentration, while the first order reaction only scales linearly.
Another factor to consider is ring strain, since certain ring sizes (e.g. 8- and 9-membered) are unusually strained. In these cases you might observe more polymerisation and less cyclization than for, say, 1,5-dibromopentane, which would generate a 6-membered and unstrained cyclohexane product.