I'm not a 456 owner and frankly haven't been under a hood of that magitude however, My experience with Pop Up headlights, power door locks, power windows and anything else servo or solenoid controlled is that the "dance" usually takes place when improper feed back is recieved by the controller. That is to say that the operating mechanism, like a garage door opener, needs to know when the device has reached the appropriate position. Another switch someplace in the system should be sending a "the light is open" indication. When the operating mechanism does not receive that information or recognizes some other issue (overtorque), it assumes a fault has taken place and reverses its instruction. The issue can be caused by mechanical interferance (something is in the way), improper adjustment (It thinks something is in the way) or electical malfunction (take me to a mechanic).
1) Look closely for mechanical interferance. It is the usual suspect.
2) Look for the "I'm Open" switch. It may not be obvious. I could be on a tether and not immediately recognizable. It can also be internal to the pod servo in which case you can't fix it.
3) Look for electical issues such as loose connections, chaffed wires or harnesses, bad fuses, etc...
If you can't find an issue, schedule an appointment or stop driving at night.
You say it only does it some times...that suggests improper adjustment of the "I'm Open" switch. Do you notice it happening more or less in warm vs. cold, wet vs. dry, or any other condition? I might suggest "helping" it realize its fully open. It when it starts to dance, grab it softly and try to push it slightly more open than it actually going. DON'T FORCE IT. just try to see if a little effort helps it see the open indicator. If this works then switch adjustment is your problem.