I’d keep your legs straight and flex your glutes.
You have trouble at the top, so try this:
Step on a high box and do some static holds with your chest touching the bar and then do a slow negative down.
Step back up, repeat.
A few sets twice a week of 5-8 reps will help quick.
Also, add in 1 pullup between all sets of assistance/accessory work-use a band if needed. Get ALL the way up.
Next week, 2 reps, week after 3 reps.
4the week, use less band and repeat. This is in addition to any other pullup work you do.
It works.