SW77 is self-contained because Lucas had no idea if any sequels would happen; hence the happy ending. Vader getting away in the end is a classic scenario from the pulp serials like Flash Gordan that Lucas loved so much.
And for the record, ESB has a happy ending. Han was in trouble yes, but they escaped from the Empire, recruited a new ally in Lando, and Luke’s power was rising. The music cue at the end is not “sad ending” music.