Fix hook when stdout is not available