Sort by z-index on close