Drupal commerce - change order status when order is locked

This is a helper function when order is locked, validation fails and status cant be changes.

$order = commerce_order_load('219215');
commerce_order_status_update($order, 'pending', FALSE, FALSE);
commerce_order_save($order);