Close all function bugfix

Standard iterator mistake