Solved it! The problem was the warm start. In particular, when the car transitions from the state
x: 7.599, y: 1.320, yaw: 3.131, speed: 1.919
to this one
x: 7.580, y: 1.318, yaw: -3.137, speed: 1.922.
the weird behaviour occours. Look at the yaw (i.e., theta) variable. Mind you, this is with theta cost set to 0.
What happens here is that with warm start enabled, which is enabled by default in the code above, the previous solution has a theta difference of 3.131 + 3.137 with respect to the current one, and the solver is not liking this.
By using cold start (setting x and u to 0) at every iteration, the problem disappears. One could also keep using warm start but by being careful and changing lbx0 and ubx0 or the previous solution trajectory to keep the theta similar between iterations.