slim: add function to exit properly

Merged Valentin Vallaeys requested to merge exit_properly into master

Merge request reports