Is this allowed?

A totally legitimate strategy -- a good plan, even, for a player down in material like your opponent was. It's up to you to prevent this by ensuring you've looked after your King's safety.
Next time, you'd probably be better to claim the draw on repetition before you time out.