[medium] fix command cleanup in scheduler