Up front, ghosting is not okay in general. But, a few counterpoints: It seems very unlikely they expected or wanted it to take you 6 hours. Possible, but certainly an outlier (and obviously bad actor) if so. If they expected you to spent 1.5-2 hours on it - a reasonable amount of time IMO - but when got it back you clearly spent an entire day working on it, that's enough to fail because you didn't follow the directio…
Yeah, let's fail someone who cares about showing their best self for an interview and takes pride in the craftsmanship of their code because we asked them to spend no time on it and probably get something that doesn't even work.
Not to mention there are probably other candidates that are taking just as long but not mentioning how long it takes them when turning it in, so the employer might start having an unreasonable expectation of the quality of work that can be done in 1.5-2 hours based on other applicants, and if you actually do follow instructions and only put that time in, you're likely going to be compared unfavorably against those other applicants.
Only way to properly enforce that limited time is to bring someone in to take a test in person, which is what my last company did (I barely passed and watched hundreds of people get brought in and not pass in the years since...in fact I saw only a handful of people pass that stupid test, part of the reason we never hired anyone, even though we needed to).