Add an optional timeout parameter when waiting for a local process to exit