Stopping form using user input

Hello everyone, I want to deactivate the forms when user wants to quit or cancel. Please help me on this. Is there any solution