Is it possible to end a program forcefully?

The Loop() will alway run.

So you must structure your program in such a way that there will be a state where the loop is "idling".

That does not mean that everything must be in the loop, you can have functions outside the loop that you call from within the loop.