How to stop tasks after test flow was finished

I have a test with the following run task:


task run_phase(uvm_phase phase);
  seq = generator_sequence::type_id::create("seq",this);
  fork
    seq.start(env.client_agent.sequencer);
    begin
      #1us;
      $display("finished waiting 1us");
    end
  join_any
  disable fork;
  seq.kill();
  phase.drop_objection(this);
endtask

Tasks in the driver continue to run although the test reached its end.
How can I make all tasks in driver, monitor etc. to stop?

In reply to zgal:

The only way this could happen is there are other outstanding objections. See Debugging/BuiltInDebug | Verification Academy

In reply to dave_59:

The only objections are in the test. I suspect that forever loop can’t be stopped by the end of run phase. I think that I have explicitly to stop those forever loops, i.e. convert forever loop to a while loop.
Dave ,Is the above true?

In reply to zgal:

How does your sequence look like? Is there a forever-loop inside? If yes the test will run forever.

In reply to zgal:

Is the objection in your test getting dropped? If not then you have a different problem.

Here is an example showing a driver with a forever loop, and the test raising the only objection.

after digging in the code I found another pair of raise & drop objections in the scoreboard. After deleting them the test stopped as expected. this is a good example of why objections should only be utilized in the test.
thanks