Yes, Steam count hours of your gameplay in the background. Once you launch a game via the Steam Client, it starts counting your gameplay time, no matter whether you left the game idle or you are playing it continuously. Steam keeps counting the hours of your gameplay until you exit the game completely.