public void terminate () 
    {
        if (!terminating && encoder != null && encoder.has_data ())
        {
            terminating = true;
            return;
        }
        unplug ();
        destroy ();
    }