I have several scripts that I have running through tasking manager that perform various functions on a file geodatabase. However when they run the generate a schema lock. Is there a graceful way to end a python script or should I use os.remove(schema.ini)?
I don't know the graceful answer, but I'll mention a workaround suggested by ESRI Tech support to me several months ago when I had some ongoing weirdness with File Geodatabase Schema locks. Their solution was to run the "Compact" tool, which includes in its functioning a Schema lock release. This cleaned up the issues on several FGDB.
Important Note - the similar-sounding process in ArcCatalog (right-click on FGDB, Administration, Compact Geodatabase) does not include as comprehensive a Schema lock clearing, so use the tool instead.
Compact
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
Chris Donohue, GISP