# Help with julia script

**URL:** <https://discourse.julialang.org/t/help-with-julia-script/28052>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 27, 2019, 4:32pm UTC](https://discourse.julialang.org/t/help-with-julia-script/28052 "2019-08-27T16:32:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonjilla](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Post date:** [August 27, 2019, 4:32pm UTC](https://discourse.julialang.org/t/help-with-julia-script/28052/1 "2019-08-27T16:32:18Z")

</div>

Hello,

I’m having a strange issue on one of my julia scripts. It clearly completes to the end, but doesn’t exit the script.

The last two lines of the script are the following.

```julia
println("all complete")
exit()

```

I can see the message “all complete” but the script doesn’t exit back to the command line. Any ideas how to debug what could be holding the script open?

---

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [August 27, 2019, 6:05pm UTC](https://discourse.julialang.org/t/help-with-julia-script/28052/2 "2019-08-27T18:05:56Z")

</div>

Can you give us a more complete example ?  
I did something very naive on a script `run.jl`:

```julia
a = 1 + 1
println("all complete")
exit()

```

and on terminal everything works well:

```julia
(base) PC@user:~$ julia run.jl 
all complete
(base) PC@user:~$

```

---

<div class="post-metadata">

**Author:** ![jonjilla](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Post date:** [August 27, 2019, 6:29pm UTC](https://discourse.julialang.org/t/help-with-julia-script/28052/3 "2019-08-27T18:29:37Z")

</div>

It’s a large script, but I’m guessing the problem is with the ODBC module that I’m using in this script. I’ve had experience before that if the ODBC connection is opened, but for some reason, it’s not disconnected, then the session hangs when trying to exit.

Since it’s not possible for me to pass the entire script with all of the custom database connections, I’m more looking suggestions on how to debug this.

For now, I’ll try to simulate the portion that connects to the database through ODBC and remove the actual connection to see if that allow the script to terminate.

---

<div class="post-metadata">

**Author:** ![jonjilla](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Post date:** [August 27, 2019, 9:24pm UTC](https://discourse.julialang.org/t/help-with-julia-script/28052/4 "2019-08-27T21:24:56Z")

</div>

Yes, it looks like the problem is with this old issue on ODBC. If I remove this portion from the script, it exits correctly. So there must be something causing the ODBC disconnect statement from being executed.

[https://github.com/JuliaDatabases/ODBC.jl/issues/172](https://github.com/JuliaDatabases/ODBC.jl/issues/172)

EDIT: I found why this was not disconnecting. I had the disconnect command in the finally block of a try/finally block. I had forgotten that try/finally blocks have separate scope (which I really cannot understand…)

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 28, 2019, 12:57am UTC](https://discourse.julialang.org/t/help-with-julia-script/28052/5 "2019-08-28T00:57:24Z")

</div>

> [@Noel\_Araujo](#):
>
> I did something very naive on a script `run.jl` :

I don’t think the `exit()` is even necessary? I thought that was strictly to leave the REPL - I’ve written a bunch of scripts and have never used that function (they end and return the command prompt fine).
