How To Close A Function In Python