During a Special Adventure, you can extend your time in two different ways:
1) Extend One Task
If you fail to complete the required amount of stars required for your active task, you will be offered to spend gems in order to increase the amount of time left in that particular task so that more stars can be gathered. Note, that this does not extend the overall duration of your Special Adventure, but rather gives you more time to finish one specific task you are in.
2) Extend the Whole Adventure
If you're running out of time on your Special Adventure, you can extend the overall duration of your quest and give yourself some extra time to finish up. To add more time to your quest, tap on the clock icon under the name of the Adventure: use 55 gems or an add-time toffee to extend the Adventure by 3 hours or watch a video ad to extend it by 20 minutes. Note, that this can only be done while your Adventure is still active!