The difference between irony and coincidence lies in the intention or purpose of the ending. Irony occurs when the outcome is contrary to what is expected or intended, and it is usually intended to convey a deeper meaning or message to the reader. Coincidence, on the other hand, is an unexpected or chance occurrence, with no particular intended meaning or message.
To determine whether the ending of a story is irony or coincidence, you need to consider the author's intention and the events that lead up to the ending. If the outcome is unexpected and contradictory to what the reader and characters expected, and there is a clear purpose or message conveyed, then it is likely irony. If the outcome is simply a chance occurrence and there is no clear message or purpose conveyed, then it is more likely a coincidence. It is also possible for an ending to have elements of both irony and coincidence.