Generalize dialog behavior when escape key is pressed. Setup dialogs via a helper function instead of making the Dialog class public