Coming in right at the end, but I've found that the replacement idle shut off valves are dire.
Having had two fail I did autopsies, both had similar problem that the internals were so poorly made that they only got halfway in before they jammed, hence giving the rough idle that you have experienced.
They also lack pull power on the electromagnet. Given that electrical performance goes down when temperature increases, their pulling power decreases.
So when you first turn the key it has enough power to just about open, then just enough pull to stay open. When you shut off and restart, it is warm, so lacks the pull to overcome the rubbish internal construction, hence it comes off (or partly off).
If the old one you have ever fails I'd look for a good second hand original.