Fix error while switching tracks on ending