Changed logic,
added CLloseAllWindows function