Non-Markovian open quantum system approach to the early Universe: Damping of gravitational waves by matter