Fix race condition in port allocation upon process termination by eliminating a goroutine.