isn't CloseMainWindow redundant? Or it leaks?