beginning of catching when principal window close