rescue bad descriptor exception in close_write