When executing the startapp function, the instance of explorer runs within a separate asynchronous process from the evaluation of the AutoLISP program, and, as such, you would need to use a function to interface with the set of running Windows processes, identify the instance of explorer (or more likely, Windows Notepad, though the program used to open the file would ultimately depend on the .txt file association configured on the user's PC), and terminate such process. However, the whole thing seems rather pointless.