A key challenge for public health policymakers is determining when an infectious disease outbreak has finished. Following a period without cases, an estimate of the probability that no further cases will occur in future (the end-of-outbreak probability) can be used to inform whether or not to declare an outbreak over. An existing quantitative approach (the Nishiura method), based on a branching process transmission model, allows the end-of-outbreak probability to be approximated from disease incidence time series, the offspring distribution and the serial interval distribution. Here, we show how the end-of-outbreak probability under the same transmission model can be calculated exactly if data describing who-infected-whom (the transmission tree) are also available (e.g. from contact tracing studies). In that scenario, our novel approach (the traced transmission method) is straightforward to use. We demonstrate this by applying the method to data from previous outbreaks of Ebola virus disease and Nipah virus infection. For both outbreaks, the traced transmission method would have determined that the outbreak was over earlier than the Nishiura method. This highlights that collection of contact tracing data and application of the traced transmission method may allow stringent control interventions to be relaxed quickly at the end of an outbreak, with only a limited risk of outbreak resurgence.