I'm not sure if this is exactly what you are looking for, but you can use the close method from the application class
public void close()
In essence, this will cause the application to stop returning any windows upon request. When the application is closed, its state is removed from the session, and the browser window is redirected to the application exit URL set using setLogoutURL (String). If the exit URL is not set, the browser window restarts and the application restarts.
source share