Question: Say I am buying stock XYZ, is it possible to close my position, in this case sell, as soon as open market hours close or do I have to wait until the next market open?

Answer: 
If you bought stock XYZ during the day, and then you sold XYZ in after hours (after 4pm ET) that same day, then it still counts as a day trade in terms of the pattern day trader rules. If you don't want it to be a day trade, then you will have to wait until the next morning to sell it.
I know that corporate actions, such as splits or dividends, are considered next day as of 20:00 eastern time. 20:00 is also the change from the PM session to "extended overnight" EXTO session.07:00 is the start of the AM session. This is info is for stocks only, other securities have their own thing. Even options exchanges have different extended hours.(which is odd considering that they are treated similar to the underlying stocks in most regulations, tax code, and the generic regular-hours examples of day trading.)
Seems to be a rather elusive topic, possibly the volumes are so low that the situation is rare, the official rules may also have sloppy semantics that just don't define the specific cutoff times.