For future reference, plants can stretch 2 or 3 times during the first two weeks depending on strain, so calculate how much room you have to work with when determining when to go to flower. If you have 5 feet, that's only about 3 feet if you take out the height of the pot and the h eight of the light, so you should flower around 1 ft.
There is a product called Bushmaster that if you spray as a foliar once at the 12/12 flip, and twice more at 7 and 14 days, is very effective at stopping this, but it's powerful stuff and could possibly burn your plants if not used right. Use at 1 ml/L. It doesn't sound like much but that's the correct ratio. And if your strain is sensitive, it might cause a hermie or two, but nothing you can't manage with careful inspections.
Good luck.