Notes on debugging and the problem itself:
Why it hangs could be too complicated to answer because generally a process not ending means something went wrong in an unexpected way and might not repeat. If it does every time you run, step through your code to identify where it hangs. All tasks should, in theory, be "endable" the way you tried. Since they aren't always, you might actually need a stronger way to kill them.
When doing something like long running device IO, you could wind up in places where the UI is freezing on things that are simply taking too much time. To be safer, start using a background thread. If you go that route, Stackoverflow already has a ton of answers to that (separate) type of question. The one I looked at just now is titled "WinForm Application UI Hangs during Long-Running Operation"
Killing it:
You can try using taskill from an elevated command prompt. To elevate the command prompt, right click and 'Run as Administrator'. (More detail in the link.)
To use taskill, the format is: taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]
If the PID of the process is 123, run taskill /pid 123
.
If you can't see PID, go to: View (menu) > Select Columns (a menu item). From there you can check the box for PID.
You can try a free tool from Microsoft called PSTools, but I've never had to resort to that. If I can't kill it with an elevated command prompt, I reboot.