Stop threads after a certain condition is true

Looking here: How to kill thread?
I think this could maybe work, but is ugly.

using .Threads

function hanging()
    while true
        println("I'm hanging on thread:", threadid())
        sleep(1)
    end
end

function wrapper_run()
    try
        hang = Threads.@spawn hanging();
        sleep(4)
        schedule(hang, ErrorException("stop"), error=true)
    catch e 
        println("Good")
    end 
    println("hello")
end

wrapper_run()

This will stop the thread after 4 seconds but not crash