Referencing only the 2018 Laws because these should be the base for moving forward.
From maul law page 74.
17. A maul ends unsuccessfully when: (I've deleted items not relevant to OP)
b. The maul collapses (not as a result of foul play).
d. The ball-carrier goes to ground and the ball is not immediately available.
e. The ball is available to be played, the referee has called “use it” and it has not been played within five seconds of the call.
Sanction: Scrum.
. . . and we also have:
18. If a maul is formed immediately after a player has directly caught an opponent’s kick in open play, a scrum that is awarded for any of the above reasons will be to the team of the ball catcher.
From the scrum law table page 91.
Infringement/stoppage Who throws in
A maul that ends unsuccessfully. The team not in possession at the start of the maul. If the referee cannot decide which team had possession, the team moving forward before the maul stopped. If neither team was moving forward, the attacking team.
An unplayable maul after kick in open play. The team in possession at the start of the maul.
Failure to “use it” at scrum, ruck or maul. The team not in possession.
Mauls can be incredibly messy. Was it caught from a kick and was the maul immediate? Was the ball stripped before or after the maul formed? Was it stalled or moving? etc. etc.
The one thing that is C & O: The ball was available, they were told to use it, they didn't. Therefore the scrum feed goes to the team not in possession.