The dog was stuck in the iron door, groaning and crying for help for hours