The ending is not as illogical as some thought.
Those who are familiar with the 80s Mr Vampire movies will fondly remember the lead actor here (Chin Siu-Ho) is playing a washed up version of himself. In his heydays, Chin was very popular as the main protagonist of the Mr Vampire movies.
He was often (or should I say always) cast as the suave elder disciple of the powerful Taoist Master, alongside a clumsy junior disciple. Although it was always his master who would save the day, Chin was always deemed as the heroic character (the nimble fighter that kicked vampire-asses, well-contrasted by his clumsy and comic junior) in the movies.
<SPOILERS BELOW>
The ending showed that in his imagination leading to his death, he couldn't let go of his past (evidently shown by his safekeeping of the costumes he used in the movies he acted in), thus creating the entire backdrop of supernatural beings and vampire. And of course in this world he created, he died as a vampire-killing hero and not as a loser who committed suicide.
The ending was a good way to loop back to the opening monologue where he mentioned something along the line of "People often said that stories in movies are absurd, however I feel that Life is even more absurd..." as the ending showed that Chin was very lost after he was past his prime and screwed up his family life and became estranged from his family (the son who came to the morgue is already a young adult and not a child as depicted in his memories).
I think Juno Mak intended to leave the ending open for different interpretations and the above is my personal one. Feel free to disagree but I feel it is quite logical.