fixed crash when closing PyScriptTask