There really isn't anything wrong with the spell, but with the set-up in combination. The DM offered destroying the altar as a way to defeat the demon, so trapping the demon became the solution instead of actually fighting the demon.
Normally, the point of the spell is to secure a creature, but...