close block correctly