Fixed flush()

Flush was changed to wait until the ring buffer is empty and to wait for the final frame to have been transmitted before being complete.

or:

flush()
    wait for ring buffer to empty;
    wait for final frame to be transmitted;
    unset transmitting;