Troubles deleting IPC queue

I'm having some troubles deleting and IPC Queue on an IRC5 controller.
The situation I'm have is, that I'm sending a bunch of IPC messages to the controller and when the queue is full I want to delete/clear it and start fresh.

I've looked a the example at (link)

The error im getting is that DeleteQueue will return that there is no queue with the specified ID although I previously received an ID just fine.
Also looping through a number range will not return a valid ID for any of the values.

Has any one had that issue befor or know what I'm doing wrong?

An error in the example;
Ipc.Exists takes a name as input not an ID.