A mix of Wait, Variable Search and If-Else should suffice here.
Tasker maintains a variable named Profiles Active, denoted by
Profiles Active (dynamic)
A comma-separated list of the currently active, named profiles in activation order. Duplicate names will appear on the list only once. The list always starts and ends with a comma to make matching easier, if it's not empty.
You can use Wait action to wait for N amount of time and then check whether your profile is active or not. If not active, exit out of the task, else, continue.
You may begin your task with these actions:
- Task → Wait → configure it
Variables → Variable Set:
Variables → Variable Search Replace:
- tick Ignore Case
- Store Matches In:
PROFILE_NAME with the name of your profile. A profile's name must be setup manually.
- Task → If:
Task → Stop
Alternatively, put any action that notifies you that the profile deactivated in the mean time.
- Task → Else
- Setup the actions you want be executed if the profile remains active after N amount of time.