In theory it shouldn't be a problem to run docker rmi on images that are currently in use, as Docker will simply skip them.
In practice this doesn't seem to be bulletproof. On more than one occasion this caused weird problems, so I prefer to only run rmi for images that I know, are not in use.
Here's the command I use to do so:
docker rmi $(docker inspect -f '{{.Image}}' `docker ps -a -q --no-trunc` | grep -v -f - <(docker images -q --no-trunc))