Begin autonomous then become user controlled

Wondering what the code would look like to have a robot begin autonomous-following a line then become user controlled to collect items from a course. Could this be accomplished with a task? Maybe, initially the robot would start a task to line follow for time or until sensor and then become user controlled? Any ideas are appreciated. Thanks