Since vanilla nwn doesn't really have any good timing functions for determining amount of seconds between X and Y, using a Heartbeat could be an answer.
The heartbeat for placeables runs more a less every 6-7 seconds.
You could use the heartbeat to increment a local variable by 1 each time, and when it reaches the threshold, it will destroy the portal.
The downside of this is that the portal will only despawn at second intervals of 6-7.
Eg: After 6 Seconds, After 12 Seconds, After 18 Seconds etc..
Or, if you wish to get more control, you can use DelayCommand - to assign a command to the portal to destroy itself after X seconds, or check for a condition to be met, before destroying itself.
Normal hb approach:
void main(){
int times = GetLocalInt(OBJECT_SELF,"Times");
times++;
//Destroy self after 30'ish seconds.
if(times >= 5){
DestroyObject(OBJECT_SELF,0.5);
}
SetLocalInt(OBJECT_SELF,"Times",times);
}
//Placeables have no 'on-spawn' event, so we need to use the hb script to kick things off
void main(){
int done = GetLocalInt(OBJECT_SELF,"Done");
if(done){
return;
}
//Destroy self after 30 seconds
DestroyObject(OBJECT_SELF,30.00);
//Alternatively, you can put a function call here that will check for a condition, then destroy self.
}