main: Write memprofile on shutdown.
main: Write memprofile on shutdown.

This modifies the --memprofile flag to write the memory profile on
shutdown as opposed to arbitrarily writing it after 20 minutes.

decred/dcrd,jrick/dcrd,jrick/dcrd,decred/dcrd