It turns out that tramp on emacs 24.4 sets $HISTFILE to /dev/null and makes bash delete /dev/null when I kill emacs.
When /dev/null is not a character device but a regular file, a lot of programs freeze. I think a program should deal with weird inputs gracefully especially when it's not obvious that some program could set HISTFILE to /dev/null and that bash could delete /dev/null if HISTFILE is /dev/null. I didn't know until today that bash deletes /dev/null if HISTFILE is set to /dev/null. While emacs needs some modifications, bash also needs to handle that scenario more gracefully because other programs can also set HISTFILE to /dev/null instead of unsetting HISTFILE and setting HISTFILESIZE to 0.