I'm assuming the group was riding a rotating paceline. If so you did the right thing. Best approach is to pull off before you feel the need to do so. You should keep your speed up as you pull off and use your strength to get back on the end of the paceline.