The Western Bulldogs nearly threw it away, but their desperation in the last quarter got them home against Melbourne.