Changed flush() to flush all bytes in buffer

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;