fix closing issues