Avoid repeating avalon_idle in do_avalon_close and extra sleep.
Create an avalon_wait_write function that is used before sending avalon idle command.