Wait for the process to end when halting the ws