Fixed bugs

Bug on Default close operation
Bug on generate when have lot of window

refactor some method .