Role of coherence in the nonequilibrium thermodynamics of quantum systems