There are two ways to solve this:
The problem you had can be explained like this:
After Screen2 has been opened, Screen1 is closed. If the app is now closed (button → close application), Screen2 is closed and it also tries to close the main screen (Screen1). Since this has already been closed, the task remains in the background and will then be executed the next time the app is started. Therefore, the app will be closed immediately the next time it is started (Screen1 closed).