Fix bug in VM resource cleanup.

Change-Id: I76abe1343f5d6569930c1af5c9e62ac6dd0606b5