How To Close Function In Python