It is instinct telling them to find a safe roost for the night. Safe to them means a roost with some height. The floor feels unsafe to their instincts so they huddle out of fear (instincts tell them to roost on a branch up in a tree to keep up away from rats, cats, weasels, etc.. It is not good to have them this develop this habit, as chickens find it stressful to work out new solutions for the night. They solve it once, then repeat it forever after.)
They typically settle on the roost an hour before sundown. They cannot see well at dusk. (Yours flew toward the window (light) in an instinctual search for more light to see a roost.) Mine in Hawaii roosted in a tree. I had to teach them by placing them on the branches the first week. I noticed if I waited till dusk, they really couldn't see the branches very well as I could, and fell off, missing a grab for a branch. The next week they spent trying to climb the tree, jumping from spot to spot on the gnarled trunk, to get up to the first branch - and had to do it in the light, not dusk. They REALLY want to roost and were trying very hard. the first branch was about four and a half feet to six feet up (ground sloped.). They were not interested in the higher branches. Mine were Brahmas, Easter Eggers and Rhode Islands - so too heavy to fly well. I think Hamburgs and lighter breeds will roost higher, my Jaerhon did. They would cry and cry the first week if they couldn't figure it out, so I helped them by lifting them into position - or throwing them
Throwing in the dusk didn't work, because they don't see as well as humans do in dusk. It worked in the light. After a week of work, I would find them all happy in position an hour before dark, a half hour before dusk. So smug.
(In Hawaii, the Hawaiian small owls and hawks were not a problem for my big girls. They took onlly chicks under 6 weeks. The trees work very well there, so I was not endangering them. It was safer than the coop, more air, was hard to keep them in a coop, they would roost on top of it)
For their age, you can make a roost in the coop a foot or so off the floor, low enough they can fly up to it. It is a big deal for them to learn how to get on the roost and settlle into what feels right to them in position to each other (rank). Mine always fought for the spot where they could look out the window. In another coop, they all fought for the place furtherst from the window.
Makes it easier if there is one roost height , not several of different heights, because height confers rank. In a month, the roost can be raised another foot or so. Just watch what they can fly easily up to or jump down from.
In my coop, the roof is 5 feet, the adult roost about forty inches high, the baby roost in the brooder pen a little lower. They could see the adults and wanted to be nearly that high.
Whenever a chicken needs to be caught, it is so easy to go in at night and lift them off a roost set no more than five or so feet high. No struggle, no running around annoying the chicken. I've seen people use the rafters or six to seven feet high roosts - and they cannot reach the chickens to pick one up, and the chickens poop on people walking around below.
I just lift them onto the roost in the coop the first three or four nights. They quickly learn. Some are slower in development and stay on the floor - I realized it was a development of their nervous systems and allowed for that. However, others couldn't get up there but WANTED to so badly they cried and cried, so I lift them up. In my coop, I had fixed their first roost up about thirty inches and placed an upside down milk crate for them to hop onto, then onto the roost. Some didn't get the two step process for another week. Its hilarious - they looked so PROUD the evening I came to help them and they had done it all themselves already.
They typically settle on the roost an hour before sundown. They cannot see well at dusk. (Yours flew toward the window (light) in an instinctual search for more light to see a roost.) Mine in Hawaii roosted in a tree. I had to teach them by placing them on the branches the first week. I noticed if I waited till dusk, they really couldn't see the branches very well as I could, and fell off, missing a grab for a branch. The next week they spent trying to climb the tree, jumping from spot to spot on the gnarled trunk, to get up to the first branch - and had to do it in the light, not dusk. They REALLY want to roost and were trying very hard. the first branch was about four and a half feet to six feet up (ground sloped.). They were not interested in the higher branches. Mine were Brahmas, Easter Eggers and Rhode Islands - so too heavy to fly well. I think Hamburgs and lighter breeds will roost higher, my Jaerhon did. They would cry and cry the first week if they couldn't figure it out, so I helped them by lifting them into position - or throwing them

(In Hawaii, the Hawaiian small owls and hawks were not a problem for my big girls. They took onlly chicks under 6 weeks. The trees work very well there, so I was not endangering them. It was safer than the coop, more air, was hard to keep them in a coop, they would roost on top of it)
For their age, you can make a roost in the coop a foot or so off the floor, low enough they can fly up to it. It is a big deal for them to learn how to get on the roost and settlle into what feels right to them in position to each other (rank). Mine always fought for the spot where they could look out the window. In another coop, they all fought for the place furtherst from the window.

In my coop, the roof is 5 feet, the adult roost about forty inches high, the baby roost in the brooder pen a little lower. They could see the adults and wanted to be nearly that high.
Whenever a chicken needs to be caught, it is so easy to go in at night and lift them off a roost set no more than five or so feet high. No struggle, no running around annoying the chicken. I've seen people use the rafters or six to seven feet high roosts - and they cannot reach the chickens to pick one up, and the chickens poop on people walking around below.
I just lift them onto the roost in the coop the first three or four nights. They quickly learn. Some are slower in development and stay on the floor - I realized it was a development of their nervous systems and allowed for that. However, others couldn't get up there but WANTED to so badly they cried and cried, so I lift them up. In my coop, I had fixed their first roost up about thirty inches and placed an upside down milk crate for them to hop onto, then onto the roost. Some didn't get the two step process for another week. Its hilarious - they looked so PROUD the evening I came to help them and they had done it all themselves already.