A two-day prison siege in Australia has ended after inmates agreed to exchange their hostage for a delivery of pizzas.