tty: Fix race condition if flushing tty flip buffers