Simplified the main loop and termination (loop uses :net_receive, while termination uses :die)