close opening file handle before exit.