Indian markets close flat after early gains, Energy and Metal stocks shine