wait for process to end