fix closing bug of scala Tail class