Shut off the gas to the fireplace and disconnect the firebox from the gas supply.
Remove the screws that attach the termination piece, on the outside wall, to the duct. Removing the termination piece allows you to adjust the duct.
Go back inside and remove the duct from the wall; it will simply pull out because it's no longer connected to the termination piece.
Fit the duct around the connection exiting the firebox. Twist the duct clockwise until it locks into place.
Set the firebox into its location with the duct going through the hole in the wall.
Go back outside and re-attach the termination piece to the outside wall.