Keep one`s nose clean

To stay out of trouble, to avoid trouble.

The boy has been able to keep his nose clean since he moved to the new town.