# How to exit application

**URL:** <https://discuss.kotlinlang.org/t/how-to-exit-application/17298>\
**Category:** Android\
**Created:** [April 23, 2020, 10:05pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298 "2020-04-23T22:05:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablolarade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablolarade/32/7460_2.png) [@pablolarade](https://discuss.kotlinlang.org/u/pablolarade)\
**Post date:** [April 23, 2020, 10:05pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/1 "2020-04-23T22:05:19Z")

</div>

hi i’m very new to Kotlin dev and i would to know how to exit app in kotlin with a button it’s seem to be  
simple i try to read doc but …

---

<div class="post-metadata">

**Author:** ![daveTheCoder](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@daveTheCoder](https://discuss.kotlinlang.org/u/daveTheCoder)\
**Post date:** [April 23, 2020, 11:05pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/2 "2020-04-23T23:05:22Z")

</div>

This is an Android app?

---

<div class="post-metadata">

**Author:** ![pablolarade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablolarade/32/7460_2.png) [@pablolarade](https://discuss.kotlinlang.org/u/pablolarade)\
**Post date:** [April 23, 2020, 11:07pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/3 "2020-04-23T23:07:02Z")

</div>

yes a kotlin app with just a mainActivity in android studio

---

<div class="post-metadata">

**Author:** ![daveTheCoder](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@daveTheCoder](https://discuss.kotlinlang.org/u/daveTheCoder)\
**Post date:** [April 23, 2020, 11:11pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/4 "2020-04-23T23:11:49Z")

</div>

My understanding that Android apps don’t “exit” themselves.

An app is closed by the Android O/S, either in response to a user action such as touching the back-arrow, or by the O/S closing the app to reclaim resources.

The app receives an event such as onStop() or onDestroy() so that it can do cleanup like saving data or releasing resources.

---

<div class="post-metadata">

**Author:** ![pablolarade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablolarade/32/7460_2.png) [@pablolarade](https://discuss.kotlinlang.org/u/pablolarade)\
**Post date:** [April 23, 2020, 11:14pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/5 "2020-04-23T23:14:58Z")

</div>

thanks for your answer .

---

<div class="post-metadata">

**Author:** ![daveTheCoder](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@daveTheCoder](https://discuss.kotlinlang.org/u/daveTheCoder)\
**Post date:** [April 23, 2020, 11:33pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/6 "2020-04-23T23:33:41Z")

</div>

I did find this article. Most of it is several years old, but there are some newer posts at the bottom:

> <https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically>

---

<div class="post-metadata">

**Author:** ![pablolarade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablolarade/32/7460_2.png) [@pablolarade](https://discuss.kotlinlang.org/u/pablolarade)\
**Post date:** [April 23, 2020, 11:48pm UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/7 "2020-04-23T23:48:55Z")

</div>

i will try this thanks ,a question :you can’t use both language in the same files Android/Kotlin  
: im using kotling as a complet beginners.

---

<div class="post-metadata">

**Author:** ![daveTheCoder](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@daveTheCoder](https://discuss.kotlinlang.org/u/daveTheCoder)\
**Post date:** [April 24, 2020, 1:30am UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/8 "2020-04-24T01:30:37Z")

</div>

By both languages, do you mean Kotlin and Java?

---

<div class="post-metadata">

**Author:** ![pablolarade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablolarade/32/7460_2.png) [@pablolarade](https://discuss.kotlinlang.org/u/pablolarade)\
**Post date:** [February 27, 2021, 9:37am UTC](https://discuss.kotlinlang.org/t/how-to-exit-application/17298/9 "2021-02-27T09:37:18Z")

</div>

Kotlin sir,
