Make sure dialogue is ended properly when closing it by using a service (Fixes #1755)