magento , how to correctly change order status to CLOSED

i try to change order status to CLOSED, but code which I use does not work for me i have this code $model = Mage::getModel(“inventorylog/inventorylog”)->load($id); $order = Mage::getModel(‘sales/order’)->loadByIncrementId($model[‘increment_id’]); $order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true); $history = $order->addStatusHistoryComment(‘Order was set to Closed due to changes in inventory log module.’, false); $history->setIsCustomerNotified(false); if($order->save()){ //set out of stock for products in order…