prevent invalid handle exception when window handle has been destroyed