How to delete the wire connecting two blocks

I have a block with variable number of outputs and at certain points in time I want to delete some of this ouputs in the run time and also deleting the wired connecting to other blocks.

I have used the following but I got an exception : object expired while solution.


Is there a better correct way to delete the wire connection my block with blocks connected with my output?