closes function