When an error occurs with for example a primitive, the main interpreter stops but the communication thread will keep running forever, as such communication.join(); in main.cpp (emulator) will never finish causing the process to stay alive forever.
To fix this, we need some kind of way to notify this loop that the process has stopped, such as a simple boolea running flag. We then set this to false at the end so that the read thread which would use while (running) instead of while(true) gracefully comes to stop, and then the thread can be joined.
Fixing this issue also fixes #310.