Add a property to App:
timerShutdown, type is Timer
Put following code in the App.Open event:
timerShutdown = New Timer
AddHandler timerShutdown.Action, AddressOf timerShutdown_Action
timerShutdown.Period = 5000
timerShutdown.mode = Timer.ModeMultiple
Next create a method in App: timerShutdown_Action
Add following code to that method.
#If DebugBuild = False Then
Dim f As FolderItem
f = GetFolderItem("")
f = GetFolderItem(f.NativePath + Lowercase(App.ExecutableFile.Name) + ".cgi")
If (f.Exists() = False) Then
If you want to update your web app on the server, all you have. to is delete the .cgi file and within 5-10 seconds your app will stop working.
For more information see this blog by @Phillip Z (all credits to Phillip for this solution)