Stop training by accuracy?

Can I tell the train script to stop when reaching a given accuracy instead of waiting for the total number of epochs?

Thank you!