That's probably the must tricky part of the replacement. I did the same thing, i just pull on my cables and the connector stays on the board. Tried many times to switch cables into but any order i try is not the good one.
The avoid this, now, when i want to pull out my fan, i just use a plate screwdriver and lift up the connector. That's work perfectly.