Fix unexpected exit at grep commands