Without showing the code, I suspect that one of your threads is calling exit. If any thread (including main thread) calls exit, the whole program exits taking everything with it. Try putting a <>; as the very last line of your main script, so it will hold on until you hit a key to exit.