How to automatically remove container on exit


I am trying to find a way to automatically remove a container when it exits, like docker run --rm does.
I have looked at the heartbeat-timeout, but since the heartbeat is sent from the browser I suppose the container will also be removed if you lose your internet connection, and I am trying to avoid that if possible.

Thanks in advance!