Am I missing something here, what is wrong with using a selection set, something like:
(defun c:hh ( / )
(setq MySS (ssget '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "*TEXT") (-4 . "OR>"))) )
(Command "-HATCH" "S" MySS "" "")
)
You could add to this looping through the selection set to remove any polyline that is not a closed polyline (internet search gave me this snippet which could be used for that https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/check-to-see-if-polyline-is-closed/td-p/859164 )
(and just to note a 'simple Lisp' is often the most complex, which makes it simple for the user, can add in checks that a polyline is closed.... the LISP gets better but not so simple)