Auto delete itself class?

After creating an instance of a class, i would like the instance to be deleted when a method inside the class is called.

eg.


private function end():Void
{
      delete this;
}

But i’ve tried this and the instance still remains.
Any ideas?
Thanks