I presume the window when closing seems to go out of the railing....
If so then you didn't put the front of the window into the railing, do this by dropping the window to the lowest or fully open and then guide the front of the window into the guardrail and then close it.