Fix wrong process end handling