Fixed the Close() function.