An out-of-control driverless freight train in Devonport had to be derailed to bring it to a stop.