# \#atexit

**URL:** https://discourse.julialang.org/tag/atexit/1498.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Save a local variable when program is killed](https://discourse.julialang.org/t/save-a-local-variable-when-program-is-killed/128218)

<div class="topic-metadata">

**Author:** [@Yue-Zhengyuan](https://discourse.julialang.org/u/Yue-Zhengyuan)\
**Replies:** 5\
**Last updated:** [April 20, 2025, 9:54pm UTC](https://discourse.julialang.org/t/save-a-local-variable-when-program-is-killed/128218 "2025-04-20T21:54:57Z")

</div>

I have a Julia program that performs some long operation on a variable, and I hope that when the program is killed by a job management system such as SLURM, the program can save the current local state of the variable to…

---

## [Error in atexit() when stopping with SIGTERM signal](https://discourse.julialang.org/t/error-in-atexit-when-stopping-with-sigterm-signal/60486)

<div class="topic-metadata">

**Author:** [@kubcoporubco](https://discourse.julialang.org/u/kubcoporubco)\
**Replies:** 0\
**Last updated:** [May 3, 2021, 9:37pm UTC](https://discourse.julialang.org/t/error-in-atexit-when-stopping-with-sigterm-signal/60486 "2021-05-03T21:37:33Z")

</div>

Hi, I am running a compiled julia application in a docker container. In the application code I am registering a zero argument function closeAll by calling the atexit(closeAll). The closeAll function should be called befo…

---

## [Ctrl-C in script: atexit is ignored](https://discourse.julialang.org/t/ctrl-c-in-script-atexit-is-ignored/82413)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 0\
**Last updated:** [June 8, 2022, 8:44am UTC](https://discourse.julialang.org/t/ctrl-c-in-script-atexit-is-ignored/82413 "2022-06-08T08:44:46Z")

</div>

I cannot seem to be able to use atexit properly, in the context of catching Ctrl-C when running a script in Julia 1.7.2: function main() atexit(() -\> println("caught")) println("started program") sleep(5) …

---

## [Running something atexit after all finalizer](https://discourse.julialang.org/t/running-something-atexit-after-all-finalizer/66778)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 3\
**Last updated:** [August 21, 2021, 3:36pm UTC](https://discourse.julialang.org/t/running-something-atexit-after-all-finalizer/66778 "2021-08-21T15:36:27Z")

</div>

I have some finalizers they need to ccall in order to free some external resources. I also have a function I need to call right at the end which completes the tear-down – it undoes something I do in \_\_init\_\_. That at-…

---

## [Problems runnig atexit() function code properly - also under julia version 0.7.0-rc3/1.0.0-rc1 - OutOfMemoryError](https://discourse.julialang.org/t/problems-runnig-atexit-function-code-properly-also-under-julia-version-0-7-0-rc3-1-0-0-rc1-outofmemoryerror/12910)

<div class="topic-metadata">

**Author:** [@oniter](https://discourse.julialang.org/u/oniter)\
**Replies:** 3\
**Last updated:** [August 7, 2018, 9:13pm UTC](https://discourse.julialang.org/t/problems-runnig-atexit-function-code-properly-also-under-julia-version-0-7-0-rc3-1-0-0-rc1-outofmemoryerror/12910 "2018-08-07T21:13:34Z")

</div>

I cannot say where the evil comes from but when I like to use the atexit() function, which you can found here in the docs I got these three kinds of error messages: ErrorException(“schedule: Task not runnable”) …

---

## [Finalizer and atexit for C library wrappers](https://discourse.julialang.org/t/finalizer-and-atexit-for-c-library-wrappers/772)

<div class="topic-metadata">

**Author:** [@friedmud](https://discourse.julialang.org/u/friedmud)\
**Replies:** 4\
**Last updated:** [January 21, 2017, 1:17am UTC](https://discourse.julialang.org/t/finalizer-and-atexit-for-c-library-wrappers/772 "2017-01-21T01:17:19Z")

</div>

I have created a module that wraps a large C library. I need to use object finalizers to run teardown functions from the C library for each Julia object I create that’s holding onto structs from the C library. I additi…
