Fixed infinite loop bug in closeProject