fix closing scanner