add a handling of closing and modify ranking.top