Using Metareasoning to Maintain and Restore Safety for Reliably Autonomy