What you are describing is an asynchronous task, meaning, you what it to end when something (values are entered) happens in the system (and raises an event) and not by the user entering/leaving the task.
Define the method as asynchronous (in SWO1) and use a terminating event to end it (in PFTC). This way the workitem will not be completed immediately but only after the event.
Raise the event from your webdynpro screen by calling the SAP_WAPI_CREATE_EVENT function module only after the user entered the relevant values.
Another way to do what you are asking is to leave the webdynpro and call a regular screen in ABAP via a function module with return values, in that case the task doesn't need to be asynchronous and you can stop it from ending by the exit_cancelled command in the method calling the FM if the returned values are not correct.