Currently activity is deleted after sending response to client which causes DB connection exit (client pid dies -> exit).
This change changes behaviour to first delete activity and then send response.
cc @lanodan since the prior change to behaviour was introduced in 244655e8