check for window handle too (to avoid exception)