Keep in mind that cancelling a thread like this won't release memory. Nim, or you, could theoretically set up a thread cancellation clean-up handler. But AFAIK this is not implemented anywhere at the moment.
Another issue, and what I suspect is the cause for you issues, is the fact that you access global memory without locks and share data between threads without any concerns about where it's freed. This likely causes some illegal state which leaves your program spinning.