I've written a script that exports each map in a map series to a tile cache. The core loop runs fine when I copy and paste into the Python window. I get three tile caches and three tile packages. But, when I run the script as a tool, a single loop finishes and then the program crashed. I'm not getting an error message, I just get the message that ArcGIS Pro has crashed. The output from the one successful loop is good, however. As you can see, I've commented out the cleanup since I have overwrite on. I'm still getting the crash.
I have an ArcGIS Desktop version of this script that also runs fine.