Better resource cleanup at end of script.