Change Map::stop to use std::function<void()>

Fixes #685